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