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