Skip to content

Commit

Permalink
feat: 备份后的文件大小为0字节,将删除备份文件 (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeessy2 committed Oct 8, 2023
1 parent 52e34b6 commit 2e94f52
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion client/delete_old_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,17 @@ func deleteLocalOlderFiles(backupConf entity.BackupConfig) {
}
backupFileNames := make([]string, len(backupFiles))
for _, backupFile := range backupFiles {
backupFileNames = append(backupFileNames, backupFile.Name())
if !backupFile.IsDir() {
info, err := backupFile.Info()
if err == nil {
if info.Size() > 0 {
backupFileNames = append(backupFileNames, backupFile.Name())
} else {
log.Println("备份后的文件大小为0字节,将删除备份文件: " + backupConf.GetProjectPath() + string(os.PathSeparator) + backupFile.Name())
os.Remove(backupConf.GetProjectPath() + string(os.PathSeparator) + backupFile.Name())
}
}
}
}

tobeDeleteFiles := util.FileNameBeforeDays(backupConf.SaveDays, backupFileNames, backupConf.ProjectName)
Expand Down

0 comments on commit 2e94f52

Please sign in to comment.