Skip to content

Commit a5629e3

Browse files
authored
fix: Fix the problem of failed MySQL permission modification (#8351)
1 parent 515d6ca commit a5629e3

4 files changed

Lines changed: 33 additions & 24 deletions

File tree

backend/app/service/cronjob_helper.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,18 @@ func (u *CronjobService) removeExpiredBackup(cronjob model.Cronjob, accountMap m
350350
if cronjob.Type == "snapshot" {
351351
for _, account := range accounts {
352352
if len(account) != 0 {
353+
if _, ok := accountMap[account]; !ok {
354+
continue
355+
}
353356
_, _ = accountMap[account].client.Delete(path.Join(accountMap[account].backupPath, "system_snapshot", records[i].FileName))
354357
}
355358
}
356359
_ = snapshotRepo.Delete(commonRepo.WithByName(strings.TrimSuffix(records[i].FileName, ".tar.gz")))
357360
} else {
358361
for _, account := range accounts {
362+
if _, ok := accountMap[account]; !ok {
363+
continue
364+
}
359365
if len(account) != 0 {
360366
_, _ = accountMap[account].client.Delete(path.Join(accountMap[account].backupPath, records[i].FileDir, records[i].FileName))
361367
}

backend/utils/mysql/client/local.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,19 @@ func (r *Local) ChangeAccess(info AccessChangeInfo) error {
188188
info.Name = "*"
189189
info.Password = r.Password
190190
}
191-
if info.Permission != info.OldPermission {
192-
if err := r.Delete(DeleteInfo{
193-
Version: info.Version,
194-
Username: info.Username,
195-
Permission: info.OldPermission,
196-
ForceDelete: true,
197-
Timeout: 300}); err != nil {
198-
return err
199-
}
200-
if info.Username == "root" {
201-
return nil
202-
}
191+
if info.Permission == info.OldPermission {
192+
return nil
193+
}
194+
if err := r.Delete(DeleteInfo{
195+
Version: info.Version,
196+
Username: info.Username,
197+
Permission: info.OldPermission,
198+
ForceDelete: true,
199+
Timeout: 300}); err != nil {
200+
return err
201+
}
202+
if info.Username == "root" {
203+
return nil
203204
}
204205
if err := r.CreateUser(CreateInfo{
205206
Name: info.Name,

backend/utils/mysql/client/remote.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,19 @@ func (r *Remote) ChangeAccess(info AccessChangeInfo) error {
199199
info.Name = "*"
200200
info.Password = r.Password
201201
}
202-
if info.Permission != info.OldPermission {
203-
if err := r.Delete(DeleteInfo{
204-
Version: info.Version,
205-
Username: info.Username,
206-
Permission: info.OldPermission,
207-
ForceDelete: true,
208-
Timeout: 300}); err != nil {
209-
return err
210-
}
211-
if info.Username == "root" {
212-
return nil
213-
}
202+
if info.Permission == info.OldPermission {
203+
return nil
204+
}
205+
if err := r.Delete(DeleteInfo{
206+
Version: info.Version,
207+
Username: info.Username,
208+
Permission: info.OldPermission,
209+
ForceDelete: true,
210+
Timeout: 300}); err != nil {
211+
return err
212+
}
213+
if info.Username == "root" {
214+
return nil
214215
}
215216
if err := r.CreateUser(CreateInfo{
216217
Name: info.Name,

frontend/src/views/cronjob/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ const onDelete = async (row: Cronjob.CronjobInfo | null) => {
288288
let ids = [];
289289
showClean.value = false;
290290
cleanData.value = false;
291+
cleanRemoteData.value = true;
291292
if (row) {
292293
ids = [row.id];
293294
names = [row.name];

0 commit comments

Comments
 (0)