From f000f8b46ca186bf8e7ede7dfc987dcbe6be77af Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Tue, 1 Aug 2023 22:05:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9B=9E=E6=BB=9A=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=88=87=E6=8D=A2=20(#1808)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/backup_app.go | 2 +- backend/app/service/backup_mysql.go | 4 ++-- backend/app/service/backup_redis.go | 2 +- backend/app/service/backup_website.go | 2 +- backend/app/service/upgrade.go | 5 +++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/backend/app/service/backup_app.go b/backend/app/service/backup_app.go index c93075108..2b3ede959 100644 --- a/backend/app/service/backup_app.go +++ b/backend/app/service/backup_app.go @@ -149,7 +149,7 @@ func handleAppRecover(install *model.AppInstall, recoverFile string, isRollback } if !isRollback { - rollbackFile := path.Join(global.CONF.System.BaseDir, fmt.Sprintf("original/app/%s_%s.tar.gz", install.Name, time.Now().Format("20060102150405"))) + rollbackFile := path.Join(global.CONF.System.TmpDir, fmt.Sprintf("app/%s_%s.tar.gz", install.Name, time.Now().Format("20060102150405"))) if err := handleAppBackup(install, path.Dir(rollbackFile), path.Base(rollbackFile)); err != nil { return fmt.Errorf("backup app %s for rollback before recover failed, err: %v", install.Name, err) } diff --git a/backend/app/service/backup_mysql.go b/backend/app/service/backup_mysql.go index 63870660b..aa9c6eb7a 100644 --- a/backend/app/service/backup_mysql.go +++ b/backend/app/service/backup_mysql.go @@ -136,8 +136,8 @@ func handleMysqlRecover(req dto.CommonRecover, isRollback bool) error { return err } - if isRollback { - rollbackFile := path.Join(global.CONF.System.BaseDir, fmt.Sprintf("original/database/%s_%s.sql.gz", req.DetailName, time.Now().Format("20060102150405"))) + if !isRollback { + rollbackFile := path.Join(global.CONF.System.TmpDir, fmt.Sprintf("database/mysql/%s_%s.sql.gz", req.DetailName, time.Now().Format("20060102150405"))) if err := cli.Backup(client.BackupInfo{ Name: req.DetailName, Format: dbInfo.Format, diff --git a/backend/app/service/backup_redis.go b/backend/app/service/backup_redis.go index be0c4c69a..7208d1f70 100644 --- a/backend/app/service/backup_redis.go +++ b/backend/app/service/backup_redis.go @@ -143,7 +143,7 @@ func handleRedisRecover(redisInfo *repo.RootInfo, recoverFile string, isRollback suffix = "tar.gz" } } - rollbackFile := path.Join(global.CONF.System.BaseDir, fmt.Sprintf("original/database/redis/%s_%s.%s", redisInfo.Name, time.Now().Format("20060102150405"), suffix)) + rollbackFile := path.Join(global.CONF.System.TmpDir, fmt.Sprintf("database/redis/%s_%s.%s", redisInfo.Name, time.Now().Format("20060102150405"), suffix)) if err := handleRedisBackup(redisInfo, path.Dir(rollbackFile), path.Base(rollbackFile)); err != nil { return fmt.Errorf("backup database %s for rollback before recover failed, err: %v", redisInfo.Name, err) } diff --git a/backend/app/service/backup_website.go b/backend/app/service/backup_website.go index b25645917..657153fc1 100644 --- a/backend/app/service/backup_website.go +++ b/backend/app/service/backup_website.go @@ -103,7 +103,7 @@ func handleWebsiteRecover(website *model.Website, recoverFile string, isRollback isOk := false if !isRollback { - rollbackFile := path.Join(global.CONF.System.BaseDir, fmt.Sprintf("original/website/%s_%s.tar.gz", website.Alias, time.Now().Format("20060102150405"))) + rollbackFile := path.Join(global.CONF.System.TmpDir, fmt.Sprintf("website/%s_%s.tar.gz", website.Alias, time.Now().Format("20060102150405"))) if err := handleWebsiteBackup(website, path.Dir(rollbackFile), path.Base(rollbackFile)); err != nil { return fmt.Errorf("backup website %s for rollback before recover failed, err: %v", website.Alias, err) } diff --git a/backend/app/service/upgrade.go b/backend/app/service/upgrade.go index 3757c09cc..0ea5b3820 100644 --- a/backend/app/service/upgrade.go +++ b/backend/app/service/upgrade.go @@ -6,6 +6,7 @@ import ( "io" "net/http" "os" + "path" "runtime" "strings" "time" @@ -86,8 +87,8 @@ func (u *UpgradeService) Upgrade(req dto.Upgrade) error { global.LOG.Info("start to upgrade now...") fileOp := files.NewFileOp() timeStr := time.Now().Format("20060102150405") - rootDir := fmt.Sprintf("%s/upgrade_%s/downloads", global.CONF.System.TmpDir, timeStr) - originalDir := fmt.Sprintf("%s/upgrade_%s/original", global.CONF.System.TmpDir, timeStr) + rootDir := path.Join(global.CONF.System.TmpDir, fmt.Sprintf("upgrade/upgrade_%s/downloads", timeStr)) + originalDir := path.Join(global.CONF.System.TmpDir, fmt.Sprintf("upgrade/upgrade_%s/original", timeStr)) if err := os.MkdirAll(rootDir, os.ModePerm); err != nil { return err }