From 35098ce79c49876fe805d75b6f6af440624ed38e Mon Sep 17 00:00:00 2001 From: ssongliu Date: Mon, 13 Mar 2023 18:37:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E6=97=B6=EF=BC=8C=E6=9C=AA=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=A4=87=E4=BB=BD=E8=AE=B0=E5=BD=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app_utils.go | 6 ++++-- backend/app/service/backup_app.go | 2 +- backend/app/service/backup_redis.go | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index 1bbf4e90d..dd5cca43f 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -4,8 +4,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/1Panel-dev/1Panel/backend/app/repo" - "github.com/1Panel-dev/1Panel/backend/utils/env" "math" "os" "path" @@ -13,6 +11,9 @@ import ( "strconv" "strings" + "github.com/1Panel-dev/1Panel/backend/app/repo" + "github.com/1Panel-dev/1Panel/backend/utils/env" + "github.com/1Panel-dev/1Panel/backend/app/dto/response" "github.com/1Panel-dev/1Panel/backend/buserr" @@ -159,6 +160,7 @@ func deleteAppInstall(ctx context.Context, install model.AppInstall, deleteBacku global.LOG.Infof("delete app %s-%s backups successful", install.App.Key, install.Name) } _ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType("app"), commonRepo.WithByName(install.App.Key), backupRepo.WithByDetailName(install.Name)) + _ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType(install.App.Key)) return nil } diff --git a/backend/app/service/backup_app.go b/backend/app/service/backup_app.go index 909cccf72..4828a477f 100644 --- a/backend/app/service/backup_app.go +++ b/backend/app/service/backup_app.go @@ -103,7 +103,7 @@ func handleAppBackup(install *model.AppInstall, backupDir, fileName string) erro } resource, _ := appInstallResourceRepo.GetFirst(appInstallResourceRepo.WithAppInstallId(install.ID)) - if resource.ID != 0 { + if resource.ID != 0 && resource.ResourceId != 0 { mysqlInfo, err := appInstallRepo.LoadBaseInfo(constant.AppMysql, "") if err != nil { return err diff --git a/backend/app/service/backup_redis.go b/backend/app/service/backup_redis.go index 9461d0228..4e3fee8de 100644 --- a/backend/app/service/backup_redis.go +++ b/backend/app/service/backup_redis.go @@ -121,7 +121,7 @@ func handleRedisRecover(redisInfo *repo.RootInfo, recoverFile string, isRollback } if appendonly == "yes" { - if !strings.HasSuffix(recoverFile, ".tar.gz") || !strings.HasSuffix(recoverFile, ".aof") { + if !strings.HasSuffix(recoverFile, ".tar.gz") && !strings.HasSuffix(recoverFile, ".aof") { return buserr.New(constant.ErrTypeOfRedis) } } else { @@ -170,7 +170,7 @@ func handleRedisRecover(redisInfo *repo.RootInfo, recoverFile string, isRollback } } else { itemName := "dump.rdb" - if redisInfo.Version == "6.0.16" { + if appendonly == "yes" && redisInfo.Version == "6.0.16" { itemName = "appendonly.aof" } input, err := ioutil.ReadFile(recoverFile) @@ -184,5 +184,6 @@ func handleRedisRecover(redisInfo *repo.RootInfo, recoverFile string, isRollback if _, err := compose.Up(composeDir + "/docker-compose.yml"); err != nil { return err } + isOk = true return nil }