From 8e620172e6d7e5031c667a185c6d843e39e01dcc Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Mon, 5 Feb 2024 10:18:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=A4=87=E4=BB=BD=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98=20(#3829)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/backup.go | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/backend/app/service/backup.go b/backend/app/service/backup.go index d8554c80f..169d4276b 100644 --- a/backend/app/service/backup.go +++ b/backend/app/service/backup.go @@ -266,22 +266,16 @@ func (u *BackupService) BatchDeleteRecord(ids []uint) error { return err } for _, record := range records { - if record.Source == "LOCAL" { - if err := os.Remove(record.FileDir + "/" + record.FileName); err != nil { - global.LOG.Errorf("remove file %s failed, err: %v", record.FileDir+record.FileName, err) - } - } else { - backupAccount, err := backupRepo.Get(commonRepo.WithByType(record.Source)) - if err != nil { - return err - } - client, err := u.NewClient(&backupAccount) - if err != nil { - return err - } - if _, err = client.Delete(record.FileDir + record.FileName); err != nil { - global.LOG.Errorf("remove file %s from %s failed, err: %v", record.FileDir+record.FileName, record.Source, err) - } + backupAccount, err := backupRepo.Get(commonRepo.WithByType(record.Source)) + if err != nil { + return err + } + client, err := u.NewClient(&backupAccount) + if err != nil { + return err + } + if _, err = client.Delete(path.Join(record.FileDir, record.FileName)); err != nil { + global.LOG.Errorf("remove file %s from %s failed, err: %v", path.Join(record.FileDir, record.FileName), record.Source, err) } } return backupRepo.DeleteRecord(context.Background(), commonRepo.WithIdsIn(ids))