From 89ab6f86b0cb5a3cb160b94c51fc03d633db5536 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 20 Jun 2023 10:01:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=B8=8A=E4=BC=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=B5=81=E6=8E=A7=E5=85=88=E4=B8=8D=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/api/v1/repo/attachments.go | 2 +- routers/repo/attachment.go | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/routers/api/v1/repo/attachments.go b/routers/api/v1/repo/attachments.go index eb758345f1..f6733707bf 100644 --- a/routers/api/v1/repo/attachments.go +++ b/routers/api/v1/repo/attachments.go @@ -67,7 +67,7 @@ func NewMultipart(ctx *context.APIContext) { defer mutex.Unlock() datasetId := ctx.QueryInt64("dataset_id") fileName := ctx.Query("file_name") - re, err := routeRepo.NewMultipartForApi(ctx.Context) + re, err := routeRepo.NewMultipartForApi(ctx.Context, true) if err != nil { ctx.JSON(200, map[string]string{ "result_code": "-1", diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 3f2e317ea5..9d0e53e9d0 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -667,7 +667,7 @@ func GetSuccessChunks(ctx *context.Context) { } -func NewMultipartForApi(ctx *context.Context) (map[string]string, error) { +func NewMultipartForApi(ctx *context.Context, isFlowControl bool) (map[string]string, error) { if !setting.Attachment.Enabled { return nil, errors.New("attachment is not enabled") } @@ -680,11 +680,12 @@ func NewMultipartForApi(ctx *context.Context) (map[string]string, error) { return nil, errors.New("Cannot upload repeatedly,name is " + ctx.Query("file_name")) } } - - err = CheckFlowForDataset(ctx) - if err != nil { - log.Info("check error," + err.Error()) - return nil, err + if isFlowControl { + err = CheckFlowForDataset(ctx) + if err != nil { + log.Info("check error," + err.Error()) + return nil, err + } } err = upload.VerifyFileType(ctx.Query("fileType"), strings.Split(setting.Attachment.AllowedTypes, ",")) if err != nil { @@ -754,7 +755,7 @@ func NewMultipartForApi(ctx *context.Context) (map[string]string, error) { } func NewMultipart(ctx *context.Context) { - re, err := NewMultipartForApi(ctx) + re, err := NewMultipartForApi(ctx, false) if err != nil { ctx.ServerError("NewMultipart failed", err) return -- 2.34.1