| @@ -40,7 +40,7 @@ func DeleteAllUnzipFile(attachment *models.Attachment, parentDir string) { | |||||
| dirArray := strings.Split(parentDir, "/") | dirArray := strings.Split(parentDir, "/") | ||||
| //if !strings.HasSuffix(attachment.Name, ".zip") { | //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") | log.Error("The file is not zip file, can not query the dir") | ||||
| return | return | ||||
| } else if attachment.DecompressState != models.DecompressStateDone { | } 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) { | func DirIndex(ctx *context.Context) { | ||||
| uuid := ctx.Params("uuid") | uuid := ctx.Params("uuid") | ||||
| parentDir := ctx.Query("parentDir") | parentDir := ctx.Query("parentDir") | ||||
| @@ -136,7 +129,7 @@ func DirIndex(ctx *context.Context) { | |||||
| } | } | ||||
| //if !strings.HasSuffix(attachment.Name, ".zip") { | //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") | 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")) | 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 | return | ||||