Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.21.12.1^2
zouap 4 years ago
parent
commit
6598821e19
2 changed files with 11 additions and 3 deletions
  1. +9
    -1
      modules/storage/obs.go
  2. +2
    -2
      routers/repo/ai_model_manage.go

+ 9
- 1
modules/storage/obs.go View File

@@ -286,9 +286,17 @@ func GetAllObsListObjectUnderDir(bucket string, prefix string) ([]FileInfo, erro
input.Prefix = prefix
output, err := ObsCli.ListObjects(input)
fileInfos := make([]FileInfo, 0)
prefixLen := len(prefix) + 1
if err == nil {
for _, val := range output.Contents {
var isDir bool
if val.Key == prefix {
continue
}
log.Info("sub str=" + val.Key[prefixLen:])
if strings.Contains(val.Key[prefixLen:], "/") {
continue
}
if strings.HasSuffix(val.Key, "/") {
isDir = true
} else {
@@ -296,7 +304,7 @@ func GetAllObsListObjectUnderDir(bucket string, prefix string) ([]FileInfo, erro
}
fileInfo := FileInfo{
ModTime: val.LastModified.Format("2006-01-02 15:04:05"),
FileName: val.Key[len(prefix)+1:],
FileName: val.Key[prefixLen:],
Size: val.Size,
IsDir: isDir,
ParenDir: "",


+ 2
- 2
routers/repo/ai_model_manage.go View File

@@ -214,7 +214,7 @@ func DownloadSingleModelFile(ctx *context.Context) {

func ShowSingleModel(ctx *context.Context) {
id := ctx.Params(":ID")
parentDir := ctx.Query("parentDir")
//parentDir := ctx.Query("parentDir")
log.Info("Show single ModelInfo start.id=" + id)
task, err := models.QueryModelById(id)
if err != nil {
@@ -223,7 +223,7 @@ func ShowSingleModel(ctx *context.Context) {
return
}
log.Info("bucket=" + setting.Bucket + " key=" + task.Path[len(setting.Bucket)+1:])
models, err := storage.GetObsListObjectByBucketAndPrefix(setting.Bucket, task.Path[len(setting.Bucket)+1:], parentDir)
models, err := storage.GetAllObsListObjectUnderDir(setting.Bucket, task.Path[len(setting.Bucket)+1:])
if err != nil {
log.Info("get model list failed:", err)
ctx.ServerError("GetObsListObject:", err)


Loading…
Cancel
Save