Browse Source

支持tar.gz及tgz格式文件解压。

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

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

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


Loading…
Cancel
Save