| @@ -286,9 +286,17 @@ func GetAllObsListObjectUnderDir(bucket string, prefix string) ([]FileInfo, erro | |||||
| input.Prefix = prefix | input.Prefix = prefix | ||||
| output, err := ObsCli.ListObjects(input) | output, err := ObsCli.ListObjects(input) | ||||
| fileInfos := make([]FileInfo, 0) | fileInfos := make([]FileInfo, 0) | ||||
| prefixLen := len(prefix) + 1 | |||||
| if err == nil { | if err == nil { | ||||
| for _, val := range output.Contents { | for _, val := range output.Contents { | ||||
| var isDir bool | 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, "/") { | if strings.HasSuffix(val.Key, "/") { | ||||
| isDir = true | isDir = true | ||||
| } else { | } else { | ||||
| @@ -296,7 +304,7 @@ func GetAllObsListObjectUnderDir(bucket string, prefix string) ([]FileInfo, erro | |||||
| } | } | ||||
| fileInfo := FileInfo{ | fileInfo := FileInfo{ | ||||
| ModTime: val.LastModified.Format("2006-01-02 15:04:05"), | ModTime: val.LastModified.Format("2006-01-02 15:04:05"), | ||||
| FileName: val.Key[len(prefix)+1:], | |||||
| FileName: val.Key[prefixLen:], | |||||
| Size: val.Size, | Size: val.Size, | ||||
| IsDir: isDir, | IsDir: isDir, | ||||
| ParenDir: "", | ParenDir: "", | ||||
| @@ -214,7 +214,7 @@ func DownloadSingleModelFile(ctx *context.Context) { | |||||
| func ShowSingleModel(ctx *context.Context) { | func ShowSingleModel(ctx *context.Context) { | ||||
| id := ctx.Params(":ID") | id := ctx.Params(":ID") | ||||
| parentDir := ctx.Query("parentDir") | |||||
| //parentDir := ctx.Query("parentDir") | |||||
| log.Info("Show single ModelInfo start.id=" + id) | log.Info("Show single ModelInfo start.id=" + id) | ||||
| task, err := models.QueryModelById(id) | task, err := models.QueryModelById(id) | ||||
| if err != nil { | if err != nil { | ||||
| @@ -223,7 +223,7 @@ func ShowSingleModel(ctx *context.Context) { | |||||
| return | return | ||||
| } | } | ||||
| log.Info("bucket=" + setting.Bucket + " key=" + task.Path[len(setting.Bucket)+1:]) | 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 { | if err != nil { | ||||
| log.Info("get model list failed:", err) | log.Info("get model list failed:", err) | ||||
| ctx.ServerError("GetObsListObject:", err) | ctx.ServerError("GetObsListObject:", err) | ||||