From ce1cb7c90b391c8dba96fb7bf1ba734c8b9e3912 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 22 Sep 2021 16:57:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=AF=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=9A=84=E8=A7=A3=E5=8E=8B=E6=96=87=E4=BB=B6=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E7=BB=9F=E4=B8=80=E4=B8=80=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/dir.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/routers/repo/dir.go b/routers/repo/dir.go index 62d842874..612019d46 100755 --- a/routers/repo/dir.go +++ b/routers/repo/dir.go @@ -40,7 +40,7 @@ func DeleteAllUnzipFile(attachment *models.Attachment, parentDir string) { dirArray := strings.Split(parentDir, "/") //if !strings.HasSuffix(attachment.Name, ".zip") { - if !isZipFile(attachment.Name) { + if !isCanDecompress(attachment.Name) { log.Error("The file is not zip file, can not query the dir") return } else if attachment.DecompressState != models.DecompressStateDone { @@ -117,13 +117,6 @@ func DeleteAllUnzipFile(attachment *models.Attachment, parentDir string) { } -func isZipFile(name string) bool { - if strings.HasSuffix(name, ".zip") || strings.HasSuffix(name, ".tar.gz") || strings.HasSuffix(name, ".tgz") { - return true - } - return false -} - func DirIndex(ctx *context.Context) { uuid := ctx.Params("uuid") parentDir := ctx.Query("parentDir") @@ -136,7 +129,7 @@ func DirIndex(ctx *context.Context) { } //if !strings.HasSuffix(attachment.Name, ".zip") { - if !isZipFile(attachment.Name) { + if !isCanDecompress(attachment.Name) { log.Error("The file is not zip file, can not query the dir") ctx.ServerError("The file is not zip file, can not query the dir", errors.New("The file is not zip file, can not query the dir")) return