From 83b5111df36da385238c9608d8b77909f582522e Mon Sep 17 00:00:00 2001 From: palytoxin Date: Thu, 20 Aug 2020 19:12:28 +0800 Subject: [PATCH] fix dataset path --- routers/repo/dir.go | 33 +++++++++++++++++---------------- templates/repo/datasets/dirs/index.tmpl | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/routers/repo/dir.go b/routers/repo/dir.go index f99b3ad95..87ec28432 100755 --- a/routers/repo/dir.go +++ b/routers/repo/dir.go @@ -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 + diff --git a/templates/repo/datasets/dirs/index.tmpl b/templates/repo/datasets/dirs/index.tmpl index a6caf79db..003fb635e 100755 --- a/templates/repo/datasets/dirs/index.tmpl +++ b/templates/repo/datasets/dirs/index.tmpl @@ -7,7 +7,7 @@

{{ range $index, $item := .Path }} - {{ $item }}/ + {{ $item }}/ {{ end }}