diff --git a/backend/app/service/app.go b/backend/app/service/app.go index c9c28a7d9..6948f1ae9 100644 --- a/backend/app/service/app.go +++ b/backend/app/service/app.go @@ -273,7 +273,7 @@ func (a AppService) Install(ctx context.Context, req request.AppInstallCreate) ( return } if list, _ := appInstallRepo.ListBy(commonRepo.WithByName(req.Name)); len(list) > 0 { - err = buserr.New(constant.ErrNameIsExist) + err = buserr.New(constant.ErrAppNameExist) return } var ( diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index ea6e08a41..aed31d4ae 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -295,6 +295,22 @@ func deleteAppInstall(install model.AppInstall, deleteBackup bool, forceDelete b switch install.App.Key { case constant.AppOpenresty: + websites, _ := websiteRepo.List() + for _, website := range websites { + if website.AppInstallID > 0 { + websiteAppInstall, _ := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID)) + if websiteAppInstall.AppId > 0 { + websiteApp, _ := appRepo.GetFirst(commonRepo.WithByID(websiteAppInstall.AppId)) + if websiteApp.Type == constant.RuntimePHP { + go func() { + _, _ = compose.Down(install.GetComposePath()) + _ = op.DeleteDir(install.GetPath()) + }() + _ = appInstallRepo.Delete(ctx, websiteAppInstall) + } + } + } + } _ = websiteRepo.DeleteAll(ctx) _ = websiteDomainRepo.DeleteAll(ctx) case constant.AppMysql, constant.AppMariaDB: diff --git a/backend/constant/errs.go b/backend/constant/errs.go index 450f29b64..818f34a45 100644 --- a/backend/constant/errs.go +++ b/backend/constant/errs.go @@ -49,7 +49,6 @@ var ( var ( ErrPortInUsed = "ErrPortInUsed" ErrAppLimit = "ErrAppLimit" - ErrFileToLarge = "ErrFileToLarge" ErrFileCanNotRead = "ErrFileCanNotRead" ErrNotInstall = "ErrNotInstall" ErrPortInOtherApp = "ErrPortInOtherApp" @@ -60,6 +59,7 @@ var ( ErrFileParse = "ErrFileParse" ErrInstallDirNotFound = "ErrInstallDirNotFound" ErrContainerName = "ErrContainerName" + ErrAppNameExist = "ErrAppNameExist" ) // website diff --git a/backend/i18n/lang/en.yaml b/backend/i18n/lang/en.yaml index 707223070..029975404 100644 --- a/backend/i18n/lang/en.yaml +++ b/backend/i18n/lang/en.yaml @@ -51,6 +51,7 @@ ErrContainerMsg: '{{ .name }} container is abnormal, please check the log on the ErrAppBackup: '{{ .name }} application backup failed err {{.err}}' ErrImagePull: '{{ .name }} image pull failed err {{.err}}' ErrVersionTooLow: 'The current 1Panel version is too low to update the app store, please upgrade the version' +ErrAppNameExist: 'App name is already exist' #file ErrFileCanNotRead: "File can not read" diff --git a/backend/i18n/lang/zh-Hant.yaml b/backend/i18n/lang/zh-Hant.yaml index bae9f92e3..f5822bb96 100644 --- a/backend/i18n/lang/zh-Hant.yaml +++ b/backend/i18n/lang/zh-Hant.yaml @@ -51,6 +51,7 @@ ErrContainerMsg: '{{ .name }} 容器異常,具體請在容器頁面查看日 ErrAppBackup: '{{ .name }} 應用備份失敗 err {{.err}}' ErrImagePull: '{{ .name }} 鏡像拉取失敗 err {{.err}}' ErrVersionTooLow: '當前 1Panel 版本過低,無法更新應用商店,請升級版本之後操作' +ErrAppNameExist: '應用名稱已存在' #file ErrFileCanNotRead: "此文件不支持預覽" diff --git a/backend/i18n/lang/zh.yaml b/backend/i18n/lang/zh.yaml index 5fc71d407..9039e1dca 100644 --- a/backend/i18n/lang/zh.yaml +++ b/backend/i18n/lang/zh.yaml @@ -51,6 +51,7 @@ ErrContainerMsg: '{{ .name }} 容器异常,具体请在容器页面查看日 ErrAppBackup: '{{ .name }} 应用备份失败 err {{.err}}' ErrImagePull: '镜像拉取失败 {{.err}}' ErrVersionTooLow: '当前 1Panel 版本过低,无法更新应用商店,请升级版本之后操作' +ErrAppNameExist: '应用名称已存在' #file ErrFileCanNotRead: "此文件不支持预览"