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