Browse Source

修改可支持的解压文件方法,统一一个

Signed-off-by: zouap <zouap@pcl.ac.cn>
pull/435/head
zouap 3 years ago
parent
commit
ce1cb7c90b
1 changed files with 2 additions and 9 deletions
  1. +2
    -9
      routers/repo/dir.go

+ 2
- 9
routers/repo/dir.go View File

@@ -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


Loading…
Cancel
Save