mirror of
https://github.com/1Panel-dev/1Panel
synced 2024-11-22 07:38:45 +00:00
fix: 解决删除备份文件路径错误的问题 (#3829)
This commit is contained in:
parent
9b8b9f505b
commit
8e620172e6
@ -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))
|
||||||
|
Loading…
Reference in New Issue
Block a user