mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-10 15:36:45 +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))
|
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithLinkId(appInstall.ID), repo.WithByFrom(constant.AppResourceLocal))
|
||||||
for _, resource := range resources {
|
for _, resource := range resources {
|
||||||
linkInstall, _ := appInstallRepo.GetFirst(repo.WithByID(resource.AppInstallId))
|
linkInstall, _ := appInstallRepo.GetFirst(repo.WithByID(resource.AppInstallId))
|
||||||
res = append(res, dto.AppResource{
|
if linkInstall.ID > 0 {
|
||||||
Type: "app",
|
res = append(res, dto.AppResource{
|
||||||
Name: linkInstall.Name,
|
Type: "app",
|
||||||
})
|
Name: linkInstall.Name,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
_ = appInstallResourceRepo.DeleteBy(context.Background(), appInstallResourceRepo.WithAppInstallId(resource.AppInstallId))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,21 +379,25 @@ func deleteAppInstall(deleteReq request.AppInstallDelete) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(install.ID))
|
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(install.ID))
|
||||||
if deleteReq.DeleteDB && len(resources) > 0 {
|
if len(resources) > 0 {
|
||||||
del := dto.DelAppLink{
|
if deleteReq.DeleteDB {
|
||||||
Ctx: ctx,
|
del := dto.DelAppLink{
|
||||||
Install: &install,
|
Ctx: ctx,
|
||||||
ForceDelete: deleteReq.ForceDelete,
|
Install: &install,
|
||||||
Task: uninstallTask,
|
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.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 {
|
if DatabaseKeys[install.App.Key] > 0 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue