From 33a0c2ba30e9135f8f4ff75c4461f756d8fcd223 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Sun, 7 Apr 2024 17:25:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=A0=E9=99=A4=E7=BD=91=E7=AB=99?= =?UTF-8?q?=E9=80=82=E9=85=8D=E9=98=B2=E7=AF=A1=E6=94=B9=20(#4415)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + backend/app/service/app_utils.go | 2 ++ backend/app/service/website.go | 9 +++------ backend/app/service/website_utils.go | 2 ++ backend/utils/xpack/xpack.go | 6 ++++++ 5 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 backend/utils/xpack/xpack.go diff --git a/.gitignore b/.gitignore index 45cd9a5c9..70048d63a 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ frontend/src/xpack backend/xpack backend/router/entry_xpack.go backend/server/init_xpack.go +backend/utils/xpack/xpack_xpack.go .history/ dist/ diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index cc7a171f2..024c9621a 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -5,6 +5,7 @@ import ( "encoding/base64" "encoding/json" "fmt" + "github.com/1Panel-dev/1Panel/backend/utils/xpack" "math" "net/http" "os" @@ -364,6 +365,7 @@ func deleteAppInstall(install model.AppInstall, deleteBackup bool, forceDelete b } _ = websiteRepo.DeleteAll(ctx) _ = websiteDomainRepo.DeleteAll(ctx) + xpack.RemoveTamper("") case constant.AppMysql, constant.AppMariaDB: _ = mysqlRepo.Delete(ctx, mysqlRepo.WithByMysqlName(install.Name)) case constant.AppPostgresql: diff --git a/backend/app/service/website.go b/backend/app/service/website.go index e6f85ab00..ef5ab8bdd 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -435,12 +435,9 @@ func (w WebsiteService) DeleteWebsite(req request.WebsiteDelete) error { } if checkIsLinkApp(website) && req.DeleteApp { - appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID)) - if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - return err - } - if !reflect.DeepEqual(model.AppInstall{}, appInstall) { - if err := deleteAppInstall(appInstall, true, req.ForceDelete, true); err != nil && !req.ForceDelete { + appInstall, _ := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID)) + if appInstall.ID > 0 { + if err = deleteAppInstall(appInstall, true, req.ForceDelete, true); err != nil && !req.ForceDelete { return err } } diff --git a/backend/app/service/website_utils.go b/backend/app/service/website_utils.go index 9e0637883..1e36b22e6 100644 --- a/backend/app/service/website_utils.go +++ b/backend/app/service/website_utils.go @@ -3,6 +3,7 @@ package service import ( "encoding/json" "fmt" + "github.com/1Panel-dev/1Panel/backend/utils/xpack" "log" "os" "path" @@ -400,6 +401,7 @@ func delNginxConfig(website model.Website, force bool) error { } sitePath := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "www", "sites", website.Alias) if fileOp.Stat(sitePath) { + xpack.RemoveTamper(website.Alias) _ = fileOp.DeleteDir(sitePath) } diff --git a/backend/utils/xpack/xpack.go b/backend/utils/xpack/xpack.go new file mode 100644 index 000000000..9c5ba63b1 --- /dev/null +++ b/backend/utils/xpack/xpack.go @@ -0,0 +1,6 @@ +//go:build !xpack + +package xpack + +func RemoveTamper(website string) { +}