diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index df9ec0a8a..c1b5a099e 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -626,7 +626,6 @@ func QueryModelListForPredict(ctx *context.Context) { func QueryModelFileForPredict(ctx *context.Context) { id := ctx.Query("ID") - parentDir := ctx.Query("parentDir") model, err := models.QueryModelById(id) if err != nil { log.Error("no such model!", err.Error()) @@ -634,9 +633,20 @@ func QueryModelFileForPredict(ctx *context.Context) { return } prefix := model.Path[len(setting.Bucket)+1:] - if parentDir != "" { - prefix = prefix + parentDir - } fileinfos, err := storage.GetAllObjectByBucketAndPrefix(setting.Bucket, prefix) ctx.JSON(http.StatusOK, fileinfos) } + +func QueryOneLevelModelFile(ctx *context.Context) { + id := ctx.Query("ID") + parentDir := ctx.Query("parentDir") + model, err := models.QueryModelById(id) + if err != nil { + log.Error("no such model!", err.Error()) + ctx.ServerError("no such model:", err) + return + } + prefix := model.Path[len(setting.Bucket)+1:] + fileinfos, err := storage.GetOneLevelAllObjectUnderDir(setting.Bucket, prefix, parentDir) + ctx.JSON(http.StatusOK, fileinfos) +} diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 547e48a4c..85921b478 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -994,6 +994,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/query_train_job_version", reqRepoCloudBrainReader, repo.QueryTrainJobVersionList) m.Get("/query_model_for_predict", reqRepoCloudBrainReader, repo.QueryModelListForPredict) m.Get("/query_modelfile_for_predict", reqRepoCloudBrainReader, repo.QueryModelFileForPredict) + m.Get("/query_onelevel_modelfile", reqRepoCloudBrainReader, repo.QueryOneLevelModelFile) m.Group("/:ID", func() { m.Get("", repo.ShowSingleModel) m.Get("/downloadsingle", repo.DownloadSingleModelFile)