|
@@ -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)
|