fix: 解决删除备份文件路径错误的问题 (#3829)

This commit is contained in:
ssongliu 2024-02-05 10:18:43 +08:00 committed by GitHub
parent 9b8b9f505b
commit 8e620172e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -266,22 +266,16 @@ func (u *BackupService) BatchDeleteRecord(ids []uint) error {
return err return err
} }
for _, record := range records { for _, record := range records {
if record.Source == "LOCAL" { backupAccount, err := backupRepo.Get(commonRepo.WithByType(record.Source))
if err := os.Remove(record.FileDir + "/" + record.FileName); err != nil { if err != nil {
global.LOG.Errorf("remove file %s failed, err: %v", record.FileDir+record.FileName, err) return err
} }
} else { client, err := u.NewClient(&backupAccount)
backupAccount, err := backupRepo.Get(commonRepo.WithByType(record.Source)) if err != nil {
if err != nil { return err
return err }
} if _, err = client.Delete(path.Join(record.FileDir, record.FileName)); err != nil {
client, err := u.NewClient(&backupAccount) global.LOG.Errorf("remove file %s from %s failed, err: %v", path.Join(record.FileDir, record.FileName), record.Source, err)
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)
}
} }
} }
return backupRepo.DeleteRecord(context.Background(), commonRepo.WithIdsIn(ids)) return backupRepo.DeleteRecord(context.Background(), commonRepo.WithIdsIn(ids))