Browse Source

fix dataset path

master
palytoxin 4 years ago
parent
commit
83b5111df3
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")
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 +


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

@@ -7,7 +7,7 @@
<div class="column sixteen wide">
<p>
{{ 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 }}
</p>
</div>


Loading…
Cancel
Save