From 71d1911eec5064dd737b4420754c6a897eaa82fc Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 22 Sep 2021 14:23:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81tar.gz=E5=8F=8Atgz=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E6=96=87=E4=BB=B6=E8=A7=A3=E5=8E=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/dir.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/routers/repo/dir.go b/routers/repo/dir.go index ea46af7fc..25fb2215d 100755 --- a/routers/repo/dir.go +++ b/routers/repo/dir.go @@ -39,7 +39,8 @@ func DeleteAllUnzipFile(attachment *models.Attachment, parentDir string) { uuid := attachment.UUID dirArray := strings.Split(parentDir, "/") - if !strings.HasSuffix(attachment.Name, ".zip") { + //if !strings.HasSuffix(attachment.Name, ".zip") { + if !isZipFile(attachment.Name) { log.Error("The file is not zip file, can not query the dir") return } else if attachment.DecompressState != models.DecompressStateDone { @@ -116,6 +117,13 @@ 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") @@ -127,7 +135,8 @@ func DirIndex(ctx *context.Context) { return } - if !strings.HasSuffix(attachment.Name, ".zip") { + //if !strings.HasSuffix(attachment.Name, ".zip") { + if !isZipFile(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