mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-14 01:34:47 +08:00
fix: 解决网站选择已有应用安装失败的BUG
This commit is contained in:
parent
e33bf51941
commit
505caa4d49
@ -153,7 +153,7 @@ func (a AppInstallService) Operate(req request.AppInstalledOperate) error {
|
||||
install.Status = constant.Running
|
||||
case constant.Delete:
|
||||
tx, ctx := getTxAndContext()
|
||||
if err := deleteAppInstall(ctx, install, req.ForceDelete, req.DeleteBackup); err != nil {
|
||||
if err := deleteAppInstall(ctx, install, req.DeleteBackup); err != nil && !req.ForceDelete {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ func createLink(ctx context.Context, app model.App, appInstall *model.AppInstall
|
||||
return nil
|
||||
}
|
||||
|
||||
func deleteAppInstall(ctx context.Context, install model.AppInstall, forceDelete bool, deleteBackup bool) error {
|
||||
func deleteAppInstall(ctx context.Context, install model.AppInstall, deleteBackup bool) error {
|
||||
op := files.NewFileOp()
|
||||
appDir := install.GetPath()
|
||||
dir, _ := os.Stat(appDir)
|
||||
@ -168,7 +168,7 @@ func deleteAppInstall(ctx context.Context, install model.AppInstall, forceDelete
|
||||
if err := appInstallRepo.Delete(ctx, install); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := deleteLink(ctx, &install); err != nil && !forceDelete {
|
||||
if err := deleteLink(ctx, &install); err != nil {
|
||||
return err
|
||||
}
|
||||
if deleteBackup {
|
||||
|
@ -101,12 +101,18 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) error {
|
||||
req.Name = create.AppInstall.Name
|
||||
req.AppDetailId = create.AppInstall.AppDetailId
|
||||
req.Params = create.AppInstall.Params
|
||||
var installErr error
|
||||
appInstall, installErr = ServiceGroupApp.Install(ctx, req)
|
||||
if installErr != nil {
|
||||
return installErr
|
||||
install, err := ServiceGroupApp.Install(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
website.AppInstallID = appInstall.ID
|
||||
website.AppInstallID = install.ID
|
||||
appInstall = install
|
||||
} else {
|
||||
install, err := appInstallRepo.GetFirst(commonRepo.WithByID(create.AppInstallID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
appInstall = &install
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,7 +271,7 @@ func (w WebsiteService) DeleteWebsite(req request.WebsiteDelete) error {
|
||||
return err
|
||||
}
|
||||
if !reflect.DeepEqual(model.AppInstall{}, appInstall) {
|
||||
if err := deleteAppInstall(ctx, appInstall, req.ForceDelete, true); err != nil {
|
||||
if err := deleteAppInstall(ctx, appInstall, true); err != nil && !req.ForceDelete {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ func handleWebsiteBackup(backupType, baseDir, backupDir, domain, backupName stri
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nginxConfFile := fmt.Sprintf("%s/nginx/%s/conf/conf.d/%s.conf", constant.AppInstallDir, nginxInfo.Name, website.PrimaryDomain)
|
||||
nginxConfFile := fmt.Sprintf("%s/nginx/%s/conf/conf.d/%s.conf", constant.AppInstallDir, nginxInfo.Name, website.Alias)
|
||||
fileOp := files.NewFileOp()
|
||||
if err := fileOp.CopyFile(nginxConfFile, tmpDir); err != nil {
|
||||
return err
|
||||
@ -423,12 +423,12 @@ func handleWebsiteBackup(backupType, baseDir, backupDir, domain, backupName stri
|
||||
return err
|
||||
}
|
||||
websiteDir := fmt.Sprintf("%s/%s/%s", constant.AppInstallDir, app.App.Key, app.Name)
|
||||
if err := handleTar(websiteDir, tmpDir, fmt.Sprintf("%s.app.tar.gz", website.PrimaryDomain), ""); err != nil {
|
||||
if err := handleTar(websiteDir, tmpDir, fmt.Sprintf("%s.app.tar.gz", website.Alias), ""); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
websiteDir := path.Join(constant.AppInstallDir, "nginx", nginxInfo.Name, "www", "sites", website.PrimaryDomain)
|
||||
if err := handleTar(websiteDir, tmpDir, fmt.Sprintf("%s.web.tar.gz", website.PrimaryDomain), ""); err != nil {
|
||||
websiteDir := path.Join(constant.AppInstallDir, "nginx", nginxInfo.Name, "www", "sites", website.Alias)
|
||||
if err := handleTar(websiteDir, tmpDir, fmt.Sprintf("%s.web.tar.gz", website.Alias), ""); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := handleTar(tmpDir, fmt.Sprintf("%s/%s", baseDir, backupDir), backupName+".tar.gz", ""); err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user