Skip to content

Commit

Permalink
error type judgment is transferred to saveFileFromContext
Browse files Browse the repository at this point in the history
  • Loading branch information
hasa1K committed Jun 14, 2024
1 parent 6704f04 commit fef181f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions sqle/api/controller/v1/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ func getFileRecordsFromZip(multipartFile multipart.File, fileHeader *multipart.F
if srcFile.NonUTF8 {
utf8NameByte, err := utils.ConvertToUtf8([]byte(fullName))
if err != nil {
if e.Is(err, utils.ErrUnknownEncoding) {
return nil, e.New("the file name contains unrecognized characters. Please ensure the file name is encoded in UTF-8 or use an English file name")
}
return nil, err
} else {
fullName = string(utf8NameByte)
Expand Down Expand Up @@ -305,9 +308,6 @@ func CreateAndAuditTask(c echo.Context) error {
return controller.JSONBaseErrorReq(c, err)
}
fileRecords, err = saveFileFromContext(c)
if e.Is(err, utils.ErrUnknownEncoding) {
return controller.JSONBaseErrorReq(c, e.New("the file name contains unrecognized characters. Please ensure the file name is encoded in UTF-8 or use an English file name"))
}
if err != nil {
return controller.JSONBaseErrorReq(c, err)
}
Expand Down Expand Up @@ -956,9 +956,6 @@ func AuditTaskGroupV1(c echo.Context) error {
return controller.JSONBaseErrorReq(c, err)
}
fileRecords, err = saveFileFromContext(c)
if e.Is(err, utils.ErrUnknownEncoding) {
return controller.JSONBaseErrorReq(c, e.New("the file name contains unrecognized characters. Please ensure the file name is encoded in UTF-8 or use an English file name"))
}
if err != nil {
return controller.JSONBaseErrorReq(c, err)
}
Expand Down

0 comments on commit fef181f

Please sign in to comment.