diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index c497675fb..de9d01234 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -205,12 +205,19 @@ func deleteModelByID(ctx *context.Context, id string) error { } err = models.DeleteModelById(id) if err == nil { //find a model to change new + aimodels := models.QueryModelByName(model.Name, model.RepoId) if model.New == MODEL_LATEST { - aimodels := models.QueryModelByName(model.Name, model.RepoId) if len(aimodels) > 0 { //udpate status and version count models.ModifyModelNewProperty(aimodels[0].ID, MODEL_LATEST, len(aimodels)) } + } else { + for _, tmpModel := range aimodels { + if tmpModel.New == MODEL_LATEST { + models.ModifyModelNewProperty(tmpModel.ID, MODEL_LATEST, len(aimodels)) + break + } + } } } }