Browse Source

Merge pull request 'fix dataset path' (#57) from fix-55-1 into develop

Reviewed-by: berry <senluowanxiangt@gmail.com>
tags/v1.21.12.1
berry 5 years ago
parent
commit
34d1ee2f3a
2 changed files with 18 additions and 17 deletions
  1. +17
    -16
      routers/repo/dir.go
  2. +1
    -1
      templates/repo/datasets/dirs/index.tmpl

+ 17
- 16
routers/repo/dir.go View File

@@ -31,24 +31,25 @@ func DirIndex(ctx *context.Context) {
parentDir := ctx.Query("parentDir") parentDir := ctx.Query("parentDir")
dirArray := strings.Split(parentDir, "/") dirArray := strings.Split(parentDir, "/")


if parentDir == "" {
attachment, err := models.GetAttachmentByUUID(uuid)
if err != nil {
ctx.ServerError("GetDatasetAttachments", err)
return
}
attachment, err := models.GetAttachmentByUUID(uuid)
if err != nil {
ctx.ServerError("GetDatasetAttachments", err)
return
}


if !strings.HasSuffix(attachment.Name, ".zip") {
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
} else if attachment.DecompressState != models.DecompressStateDone {
log.Error("The file has not been decompressed completely now")
ctx.ServerError("The file has not been decompressed completely now", errors.New("The file has not been decompressed completely now"))
return
}
if !strings.HasSuffix(attachment.Name, ".zip") {
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
} else if attachment.DecompressState != models.DecompressStateDone {
log.Error("The file has not been decompressed completely now")
ctx.ServerError("The file has not been decompressed completely now", errors.New("The file has not been decompressed completely now"))
return
}


// ctx.Data["OriginName"] = attachment.Name
dirArray = append([]string{attachment.Name}, dirArray...)
if parentDir == "" {
dirArray = []string{attachment.Name}
} }


files, err := ioutil.ReadDir(setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + setting.Attachment.Minio.BasePath + files, err := ioutil.ReadDir(setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + setting.Attachment.Minio.BasePath +


+ 1
- 1
templates/repo/datasets/dirs/index.tmpl View File

@@ -7,7 +7,7 @@
<div class="column sixteen wide"> <div class="column sixteen wide">
<p> <p>
{{ range $index, $item := .Path }} {{ range $index, $item := .Path }}
<a href='{{$.Link}}/?parentDir={{if gt $index 0}}{{DatasetPathJoin $.Path $index "/"}}{{else}}{{$item}}{{end}}'>{{ $item }}</a>/
<a href='{{$.Link}}/?parentDir={{if gt $index 0}}{{DatasetPathJoin $.Path $index "/"}}{{else}}{{end}}'>{{ $item }}</a>/
{{ end }} {{ end }}
</p> </p>
</div> </div>


Loading…
Cancel
Save