fix: 解决强制删除 Openresty 没有同步删除 PHP 应用的问题 (#2492)

pull/2497/head
zhengkunwang 1 year ago committed by GitHub
parent 09341d2254
commit b628bce4f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 (

@ -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:

@ -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

@ -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"

@ -51,6 +51,7 @@ ErrContainerMsg: '{{ .name }} 容器異常,具體請在容器頁面查看日
ErrAppBackup: '{{ .name }} 應用備份失敗 err {{.err}}'
ErrImagePull: '{{ .name }} 鏡像拉取失敗 err {{.err}}'
ErrVersionTooLow: '當前 1Panel 版本過低,無法更新應用商店,請升級版本之後操作'
ErrAppNameExist: '應用名稱已存在'
#file
ErrFileCanNotRead: "此文件不支持預覽"

@ -51,6 +51,7 @@ ErrContainerMsg: '{{ .name }} 容器异常,具体请在容器页面查看日
ErrAppBackup: '{{ .name }} 应用备份失败 err {{.err}}'
ErrImagePull: '镜像拉取失败 {{.err}}'
ErrVersionTooLow: '当前 1Panel 版本过低,无法更新应用商店,请升级版本之后操作'
ErrAppNameExist: '应用名称已存在'
#file
ErrFileCanNotRead: "此文件不支持预览"

Loading…
Cancel
Save