From fef181f093bf91f9d086025cded9e82aa32043e8 Mon Sep 17 00:00:00 2001 From: bianyucheng Date: Fri, 14 Jun 2024 17:17:42 +0800 Subject: [PATCH] error type judgment is transferred to saveFileFromContext --- sqle/api/controller/v1/task.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sqle/api/controller/v1/task.go b/sqle/api/controller/v1/task.go index cd0b481668..6c603982c5 100644 --- a/sqle/api/controller/v1/task.go +++ b/sqle/api/controller/v1/task.go @@ -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) @@ -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) } @@ -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) }