diff --git a/backend/app/service/cronjob_helper.go b/backend/app/service/cronjob_helper.go index 57c7be820..9d1f90e0d 100644 --- a/backend/app/service/cronjob_helper.go +++ b/backend/app/service/cronjob_helper.go @@ -350,12 +350,18 @@ func (u *CronjobService) removeExpiredBackup(cronjob model.Cronjob, accountMap m if cronjob.Type == "snapshot" { for _, account := range accounts { if len(account) != 0 { + if _, ok := accountMap[account]; !ok { + continue + } _, _ = accountMap[account].client.Delete(path.Join(accountMap[account].backupPath, "system_snapshot", records[i].FileName)) } } _ = snapshotRepo.Delete(commonRepo.WithByName(strings.TrimSuffix(records[i].FileName, ".tar.gz"))) } else { for _, account := range accounts { + if _, ok := accountMap[account]; !ok { + continue + } if len(account) != 0 { _, _ = accountMap[account].client.Delete(path.Join(accountMap[account].backupPath, records[i].FileDir, records[i].FileName)) } diff --git a/backend/utils/mysql/client/local.go b/backend/utils/mysql/client/local.go index e838882a9..dd9376ad5 100644 --- a/backend/utils/mysql/client/local.go +++ b/backend/utils/mysql/client/local.go @@ -188,18 +188,19 @@ func (r *Local) ChangeAccess(info AccessChangeInfo) error { info.Name = "*" info.Password = r.Password } - if info.Permission != info.OldPermission { - if err := r.Delete(DeleteInfo{ - Version: info.Version, - Username: info.Username, - Permission: info.OldPermission, - ForceDelete: true, - Timeout: 300}); err != nil { - return err - } - if info.Username == "root" { - return nil - } + if info.Permission == info.OldPermission { + return nil + } + if err := r.Delete(DeleteInfo{ + Version: info.Version, + Username: info.Username, + Permission: info.OldPermission, + ForceDelete: true, + Timeout: 300}); err != nil { + return err + } + if info.Username == "root" { + return nil } if err := r.CreateUser(CreateInfo{ Name: info.Name, diff --git a/backend/utils/mysql/client/remote.go b/backend/utils/mysql/client/remote.go index 0040254c7..794bb0e9d 100644 --- a/backend/utils/mysql/client/remote.go +++ b/backend/utils/mysql/client/remote.go @@ -199,18 +199,19 @@ func (r *Remote) ChangeAccess(info AccessChangeInfo) error { info.Name = "*" info.Password = r.Password } - if info.Permission != info.OldPermission { - if err := r.Delete(DeleteInfo{ - Version: info.Version, - Username: info.Username, - Permission: info.OldPermission, - ForceDelete: true, - Timeout: 300}); err != nil { - return err - } - if info.Username == "root" { - return nil - } + if info.Permission == info.OldPermission { + return nil + } + if err := r.Delete(DeleteInfo{ + Version: info.Version, + Username: info.Username, + Permission: info.OldPermission, + ForceDelete: true, + Timeout: 300}); err != nil { + return err + } + if info.Username == "root" { + return nil } if err := r.CreateUser(CreateInfo{ Name: info.Name, diff --git a/frontend/src/views/cronjob/index.vue b/frontend/src/views/cronjob/index.vue index 979f699c3..31c7ca516 100644 --- a/frontend/src/views/cronjob/index.vue +++ b/frontend/src/views/cronjob/index.vue @@ -288,6 +288,7 @@ const onDelete = async (row: Cronjob.CronjobInfo | null) => { let ids = []; showClean.value = false; cleanData.value = false; + cleanRemoteData.value = true; if (row) { ids = [row.id]; names = [row.name];