From 8660ac6fe59a7c9fe0d939a98f92fd81715efba5 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:06:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=A4=87=E4=BB=BD=E6=81=A2=E5=A4=8D=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98=20(#2879)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs https://github.com/1Panel-dev/1Panel/issues/2854 --- backend/app/model/app_install.go | 8 ++++---- backend/app/service/backup_app.go | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/backend/app/model/app_install.go b/backend/app/model/app_install.go index 0049b637d..539b131ba 100644 --- a/backend/app/model/app_install.go +++ b/backend/app/model/app_install.go @@ -27,18 +27,18 @@ type AppInstall struct { } func (i *AppInstall) GetPath() string { - return path.Join(i.getAppPath(), i.Name) + return path.Join(i.GetAppPath(), i.Name) } func (i *AppInstall) GetComposePath() string { - return path.Join(i.getAppPath(), i.Name, "docker-compose.yml") + return path.Join(i.GetAppPath(), i.Name, "docker-compose.yml") } func (i *AppInstall) GetEnvPath() string { - return path.Join(i.getAppPath(), i.Name, ".env") + return path.Join(i.GetAppPath(), i.Name, ".env") } -func (i *AppInstall) getAppPath() string { +func (i *AppInstall) GetAppPath() string { if i.App.Resource == constant.AppResourceLocal { return path.Join(constant.LocalAppInstallDir, strings.TrimPrefix(i.App.Key, constant.AppResourceLocal)) } else { diff --git a/backend/app/service/backup_app.go b/backend/app/service/backup_app.go index 8947c3776..0ba62e5a3 100644 --- a/backend/app/service/backup_app.go +++ b/backend/app/service/backup_app.go @@ -225,7 +225,7 @@ func handleAppRecover(install *model.AppInstall, recoverFile string, isRollback _ = fileOp.Rename(appDir, backPath) _ = fileOp.CreateDir(appDir, 0755) - if err := handleUnTar(tmpPath+"/app.tar.gz", fmt.Sprintf("%s/%s", constant.AppInstallDir, install.App.Key)); err != nil { + if err := handleUnTar(tmpPath+"/app.tar.gz", install.GetAppPath()); err != nil { global.LOG.Errorf("handle recover from app.tar.gz failed, err: %v", err) _ = fileOp.DeleteDir(appDir) _ = fileOp.Rename(backPath, appDir) @@ -248,8 +248,6 @@ func handleAppRecover(install *model.AppInstall, recoverFile string, isRollback oldInstall.AppId = install.AppId oldInstall.AppDetailId = install.AppDetailId oldInstall.App.ID = install.AppId - oldInstall.Env = strings.ReplaceAll(oldInstall.Env, oldInstall.ContainerName, install.ContainerName) - oldInstall.ContainerName = install.ContainerName if err := appInstallRepo.Save(context.Background(), &oldInstall); err != nil { global.LOG.Errorf("save db app install failed, err: %v", err) return err