diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-02-09 15:16:14 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-09-14 16:58:25 -0400 |
commit | 6b347b83a7c588638224a02840b1d90b4557ea2a (patch) | |
tree | 1e0d417a75e9d68b879ec10e2122411d4c04681c /src | |
parent | 6fdb29d806eddd17f0ac33401781f7df58639075 (diff) | |
download | SMAPI-6b347b83a7c588638224a02840b1d90b4557ea2a.tar.gz SMAPI-6b347b83a7c588638224a02840b1d90b4557ea2a.tar.bz2 SMAPI-6b347b83a7c588638224a02840b1d90b4557ea2a.zip |
fix Save Backup not pruning old backups if they're uncompressed
Diffstat (limited to 'src')
-rw-r--r-- | src/SMAPI.Mods.SaveBackup/ModEntry.cs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/SMAPI.Mods.SaveBackup/ModEntry.cs b/src/SMAPI.Mods.SaveBackup/ModEntry.cs index 30dbfbe6..33adf76d 100644 --- a/src/SMAPI.Mods.SaveBackup/ModEntry.cs +++ b/src/SMAPI.Mods.SaveBackup/ModEntry.cs @@ -124,20 +124,23 @@ namespace StardewModdingAPI.Mods.SaveBackup try { var oldBackups = backupFolder - .GetFiles() + .GetFileSystemInfos() .OrderByDescending(p => p.CreationTimeUtc) .Skip(backupsToKeep); - foreach (FileInfo file in oldBackups) + foreach (FileSystemInfo entry in oldBackups) { try { - this.Monitor.Log($"Deleting {file.Name}...", LogLevel.Trace); - file.Delete(); + this.Monitor.Log($"Deleting {entry.Name}...", LogLevel.Trace); + if (entry is DirectoryInfo folder) + folder.Delete(recursive: true); + else + entry.Delete(); } catch (Exception ex) { - this.Monitor.Log($"Error deleting old save backup '{file.Name}': {ex}", LogLevel.Error); + this.Monitor.Log($"Error deleting old save backup '{entry.Name}': {ex}", LogLevel.Error); } } } |