|
|
@@ -247,7 +247,7 @@ func SaveLocalModel(ctx *context.Context) { |
|
|
|
model := &models.AiModelManage{ |
|
|
|
ID: id, |
|
|
|
Version: version, |
|
|
|
ModelType: 1, |
|
|
|
ModelType: MODEL_LOCAL_TYPE, |
|
|
|
VersionCount: len(aimodels) + 1, |
|
|
|
Label: label, |
|
|
|
Name: name, |
|
|
@@ -433,6 +433,51 @@ func downloadModelFromCloudBrainOne(modelUUID string, jobName string, parentDir |
|
|
|
return "", 0, nil |
|
|
|
} |
|
|
|
} |
|
|
|
func DeleteModelFile(ctx *context.Context) { |
|
|
|
log.Info("delete model start.") |
|
|
|
id := ctx.Query("id") |
|
|
|
fileName := ctx.Query("fileName") |
|
|
|
model, err := models.QueryModelById(id) |
|
|
|
if err == nil { |
|
|
|
if model.ModelType == MODEL_LOCAL_TYPE { |
|
|
|
if model.Type == models.TypeCloudBrainOne { |
|
|
|
bucketName := setting.Attachment.Minio.Bucket |
|
|
|
log.Info("bucket=" + bucketName + " path=" + model.Path[len(bucketName)+1:] + fileName) |
|
|
|
if strings.HasPrefix(model.Path, bucketName+"/"+Model_prefix) { |
|
|
|
err := storage.Attachments.DeleteDir(model.Path[len(bucketName)+1:] + fileName) |
|
|
|
if err != nil { |
|
|
|
log.Info("Failed to delete model. id=" + id) |
|
|
|
} else { |
|
|
|
re := map[string]string{ |
|
|
|
"code": "-1", |
|
|
|
} |
|
|
|
re["msg"] = err.Error() |
|
|
|
ctx.JSON(200, re) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} else if model.Type == models.TypeCloudBrainTwo { |
|
|
|
log.Info("bucket=" + setting.Bucket + " path=" + model.Path[len(setting.Bucket)+1:] + fileName) |
|
|
|
if strings.HasPrefix(model.Path, setting.Bucket+"/"+Model_prefix) { |
|
|
|
err := storage.ObsRemoveObject(setting.Bucket, model.Path[len(setting.Bucket)+1:]+fileName) |
|
|
|
if err != nil { |
|
|
|
log.Info("Failed to delete model. id=" + id) |
|
|
|
} else { |
|
|
|
re := map[string]string{ |
|
|
|
"code": "-1", |
|
|
|
} |
|
|
|
re["msg"] = err.Error() |
|
|
|
ctx.JSON(200, re) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"code": "0", |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func DeleteModel(ctx *context.Context) { |
|
|
|
log.Info("delete model start.") |
|
|
|