diff --git a/models/ai_model_manage.go b/models/ai_model_manage.go index e30568afc..38f387bf8 100644 --- a/models/ai_model_manage.go +++ b/models/ai_model_manage.go @@ -125,8 +125,11 @@ func QueryModelById(id string) (*AiModelManage, error) { err := sess.Find(&aiModelManageList) if err == nil { if len(aiModelManageList) == 1 { + log.Info("return a model.") return aiModelManageList[0], nil } + } else { + log.Info("error=" + err.Error()) } return nil, err } diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index b0937aa6d..3db263d85 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -782,20 +782,22 @@ func QueryModelListForPredict(ctx *context.Context) { func QueryModelFileForPredict(ctx *context.Context) { id := ctx.Query("ID") model, err := models.QueryModelById(id) - if err != nil { + if err == nil { + if model.Type == models.TypeCloudBrainTwo { + prefix := model.Path[len(setting.Bucket)+1:] + fileinfos, _ := storage.GetAllObjectByBucketAndPrefix(setting.Bucket, prefix) + ctx.JSON(http.StatusOK, fileinfos) + } else if model.Type == models.TypeCloudBrainOne { + prefix := model.Path[len(setting.Attachment.Minio.Bucket)+1:] + fileinfos, _ := storage.GetAllObjectByBucketAndPrefixMinio(setting.Attachment.Minio.Bucket, prefix) + ctx.JSON(http.StatusOK, fileinfos) + } + } else { log.Error("no such model!", err.Error()) ctx.ServerError("no such model:", err) return } - if model.Type == models.TypeCloudBrainTwo { - prefix := model.Path[len(setting.Bucket)+1:] - fileinfos, _ := storage.GetAllObjectByBucketAndPrefix(setting.Bucket, prefix) - ctx.JSON(http.StatusOK, fileinfos) - } else if model.Type == models.TypeCloudBrainOne { - prefix := model.Path[len(setting.Attachment.Minio.Bucket)+1:] - fileinfos, _ := storage.GetAllObjectByBucketAndPrefixMinio(setting.Attachment.Minio.Bucket, prefix) - ctx.JSON(http.StatusOK, fileinfos) - } + } func QueryOneLevelModelFile(ctx *context.Context) {