mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-09 11:55:52 +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,
|
Remark: create.Remark,
|
||||||
Status: constant.WebRunning,
|
Status: constant.WebRunning,
|
||||||
ExpireDate: defaultDate,
|
ExpireDate: defaultDate,
|
||||||
AppInstallID: create.AppInstallID,
|
|
||||||
WebsiteGroupID: create.WebsiteGroupID,
|
WebsiteGroupID: create.WebsiteGroupID,
|
||||||
RuntimeID: create.RuntimeID,
|
|
||||||
Protocol: constant.ProtocolHTTP,
|
Protocol: constant.ProtocolHTTP,
|
||||||
Proxy: create.Proxy,
|
Proxy: create.Proxy,
|
||||||
AccessLog: true,
|
AccessLog: true,
|
||||||
|
|
@ -194,6 +192,7 @@ func (w WebsiteService) CreateWebsite(ctx context.Context, create request.Websit
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
website.RuntimeID = runtime.ID
|
||||||
if runtime.Resource == constant.ResourceAppstore {
|
if runtime.Resource == constant.ResourceAppstore {
|
||||||
var req request.AppInstallCreate
|
var req request.AppInstallCreate
|
||||||
reg, _ := regexp.Compile(`[^a-z0-9_-]+`)
|
reg, _ := regexp.Compile(`[^a-z0-9_-]+`)
|
||||||
|
|
@ -313,11 +312,7 @@ func (w WebsiteService) DeleteWebsite(ctx context.Context, req request.WebsiteDe
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.DeleteApp {
|
if checkIsLinkApp(website) && req.DeleteApp {
|
||||||
websites, _ := websiteRepo.GetBy(websiteRepo.WithAppInstallId(website.AppInstallID))
|
|
||||||
if len(websites) > 1 {
|
|
||||||
return buserr.New(constant.ErrAppDelete)
|
|
||||||
}
|
|
||||||
appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID))
|
appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID))
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -493,3 +493,14 @@ func opWebsite(website *model.Website, operate string) error {
|
||||||
}
|
}
|
||||||
return nginxCheckAndReload(nginxInstall.SiteConfig.OldContent, config.FilePath, nginxInstall.Install.ContainerName)
|
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',
|
value: 'deployment',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: i18n.global.t('website.static'),
|
label: i18n.global.t('runtime.runtime'),
|
||||||
value: 'static',
|
value: 'runtime',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
label: i18n.global.t('website.proxy'),
|
label: i18n.global.t('website.proxy'),
|
||||||
value: 'proxy',
|
value: 'proxy',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: i18n.global.t('runtime.runtime'),
|
label: i18n.global.t('website.static'),
|
||||||
value: 'runtime',
|
value: 'static',
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue