From 8bc6b409d933fc44713529037775e4c3d4404c1e Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Wed, 13 Sep 2023 18:18:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=20mariadb=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=B2=A1=E6=9C=89=E5=90=8C=E6=AD=A5=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E8=A1=A8=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#2280)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app_utils.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index b5c604ff2..5c19f9db4 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -252,14 +252,20 @@ func deleteAppInstall(install model.AppInstall, deleteBackup bool, forceDelete b if err := deleteLink(ctx, &install, deleteDB, forceDelete, deleteBackup); err != nil && !forceDelete { return err } - if install.App.Key == constant.AppOpenresty { + + if DatabaseKeys[install.App.Key] > 0 { + _ = databaseRepo.Delete(ctx, databaseRepo.WithAppInstallID(install.ID)) + } + + switch install.App.Key { + case constant.AppOpenresty: _ = websiteRepo.DeleteAll(ctx) _ = websiteDomainRepo.DeleteAll(ctx) - } - _ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType("app"), commonRepo.WithByName(install.App.Key), backupRepo.WithByDetailName(install.Name)) - if install.App.Key == constant.AppMysql || install.App.Key == constant.AppMariaDB { + case constant.AppMysql, constant.AppMariaDB: _ = mysqlRepo.Delete(ctx, mysqlRepo.WithByMysqlName(install.Name)) } + + _ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType("app"), commonRepo.WithByName(install.App.Key), backupRepo.WithByDetailName(install.Name)) uploadDir := path.Join(global.CONF.System.BaseDir, fmt.Sprintf("1panel/uploads/app/%s/%s", install.App.Key, install.Name)) if _, err := os.Stat(uploadDir); err == nil { _ = os.RemoveAll(uploadDir) @@ -278,10 +284,7 @@ func deleteAppInstall(install model.AppInstall, deleteBackup bool, forceDelete b } func deleteLink(ctx context.Context, install *model.AppInstall, deleteDB bool, forceDelete bool, deleteBackup bool) error { - if DatabaseKeys[install.App.Key] > 0 { - _ = databaseRepo.Delete(ctx, databaseRepo.WithAppInstallID(install.ID)) - _ = mysqlRepo.Delete(ctx, mysqlRepo.WithByMysqlName(install.Name)) - } + resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(install.ID)) if len(resources) == 0 { return nil