mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-09 15:06:37 +08:00
fix: Resolve the issue of database uninstallation failure (#9361)
This commit is contained in:
parent
7a45548387
commit
c522295c56
2 changed files with 25 additions and 17 deletions
|
@ -631,10 +631,14 @@ func (a *AppInstallService) DeleteCheck(installID uint) ([]dto.AppResource, erro
|
|||
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithLinkId(appInstall.ID), repo.WithByFrom(constant.AppResourceLocal))
|
||||
for _, resource := range resources {
|
||||
linkInstall, _ := appInstallRepo.GetFirst(repo.WithByID(resource.AppInstallId))
|
||||
res = append(res, dto.AppResource{
|
||||
Type: "app",
|
||||
Name: linkInstall.Name,
|
||||
})
|
||||
if linkInstall.ID > 0 {
|
||||
res = append(res, dto.AppResource{
|
||||
Type: "app",
|
||||
Name: linkInstall.Name,
|
||||
})
|
||||
} else {
|
||||
_ = appInstallResourceRepo.DeleteBy(context.Background(), appInstallResourceRepo.WithAppInstallId(resource.AppInstallId))
|
||||
}
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
|
|
@ -379,21 +379,25 @@ func deleteAppInstall(deleteReq request.AppInstallDelete) error {
|
|||
}
|
||||
|
||||
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(install.ID))
|
||||
if deleteReq.DeleteDB && len(resources) > 0 {
|
||||
del := dto.DelAppLink{
|
||||
Ctx: ctx,
|
||||
Install: &install,
|
||||
ForceDelete: deleteReq.ForceDelete,
|
||||
Task: uninstallTask,
|
||||
}
|
||||
t.LogWithOps(task.TaskDelete, i18n.GetMsgByKey("Database"))
|
||||
if err = deleteLink(del); err != nil {
|
||||
t.LogFailedWithOps(task.TaskDelete, i18n.GetMsgByKey("Database"), err)
|
||||
if !deleteReq.ForceDelete {
|
||||
return err
|
||||
if len(resources) > 0 {
|
||||
if deleteReq.DeleteDB {
|
||||
del := dto.DelAppLink{
|
||||
Ctx: ctx,
|
||||
Install: &install,
|
||||
ForceDelete: deleteReq.ForceDelete,
|
||||
Task: uninstallTask,
|
||||
}
|
||||
t.LogWithOps(task.TaskDelete, i18n.GetMsgByKey("Database"))
|
||||
if err = deleteLink(del); err != nil {
|
||||
t.LogFailedWithOps(task.TaskDelete, i18n.GetMsgByKey("Database"), err)
|
||||
if !deleteReq.ForceDelete {
|
||||
return err
|
||||
}
|
||||
}
|
||||
t.LogSuccessWithOps(task.TaskDelete, i18n.GetMsgByKey("Database"))
|
||||
} else {
|
||||
_ = appInstallResourceRepo.DeleteBy(ctx, appInstallResourceRepo.WithAppInstallId(install.ID))
|
||||
}
|
||||
t.LogSuccessWithOps(task.TaskDelete, i18n.GetMsgByKey("Database"))
|
||||
}
|
||||
|
||||
if DatabaseKeys[install.App.Key] > 0 {
|
||||
|
|
Loading…
Add table
Reference in a new issue