mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-24 14:54:43 +08:00
fix: 解决本地运行环境网站被删除之后 误删其他应用的BUG (#566)
This commit is contained in:
parent
d00e5b0421
commit
12d010351a
3 changed files with 18 additions and 11 deletions
|
@ -138,9 +138,7 @@ func (w WebsiteService) CreateWebsite(ctx context.Context, create request.Websit
|
|||
Remark: create.Remark,
|
||||
Status: constant.WebRunning,
|
||||
ExpireDate: defaultDate,
|
||||
AppInstallID: create.AppInstallID,
|
||||
WebsiteGroupID: create.WebsiteGroupID,
|
||||
RuntimeID: create.RuntimeID,
|
||||
Protocol: constant.ProtocolHTTP,
|
||||
Proxy: create.Proxy,
|
||||
AccessLog: true,
|
||||
|
@ -194,6 +192,7 @@ func (w WebsiteService) CreateWebsite(ctx context.Context, create request.Websit
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
website.RuntimeID = runtime.ID
|
||||
if runtime.Resource == constant.ResourceAppstore {
|
||||
var req request.AppInstallCreate
|
||||
reg, _ := regexp.Compile(`[^a-z0-9_-]+`)
|
||||
|
@ -313,11 +312,7 @@ func (w WebsiteService) DeleteWebsite(ctx context.Context, req request.WebsiteDe
|
|||
return err
|
||||
}
|
||||
|
||||
if req.DeleteApp {
|
||||
websites, _ := websiteRepo.GetBy(websiteRepo.WithAppInstallId(website.AppInstallID))
|
||||
if len(websites) > 1 {
|
||||
return buserr.New(constant.ErrAppDelete)
|
||||
}
|
||||
if checkIsLinkApp(website) && req.DeleteApp {
|
||||
appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID))
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
|
|
|
@ -493,3 +493,14 @@ func opWebsite(website *model.Website, operate string) error {
|
|||
}
|
||||
return nginxCheckAndReload(nginxInstall.SiteConfig.OldContent, config.FilePath, nginxInstall.Install.ContainerName)
|
||||
}
|
||||
|
||||
func checkIsLinkApp(website model.Website) bool {
|
||||
if website.Type == constant.Deployment {
|
||||
return true
|
||||
}
|
||||
if website.Type == constant.Runtime {
|
||||
runtime, _ := runtimeRepo.GetFirst(commonRepo.WithByID(website.RuntimeID))
|
||||
return runtime.Resource == constant.AppResourceRemote
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -11,16 +11,17 @@
|
|||
value: 'deployment',
|
||||
},
|
||||
{
|
||||
label: i18n.global.t('website.static'),
|
||||
value: 'static',
|
||||
label: i18n.global.t('runtime.runtime'),
|
||||
value: 'runtime',
|
||||
},
|
||||
|
||||
{
|
||||
label: i18n.global.t('website.proxy'),
|
||||
value: 'proxy',
|
||||
},
|
||||
{
|
||||
label: i18n.global.t('runtime.runtime'),
|
||||
value: 'runtime',
|
||||
label: i18n.global.t('website.static'),
|
||||
value: 'static',
|
||||
},
|
||||
]"
|
||||
:key="item.value"
|
||||
|
|
Loading…
Reference in a new issue