diff --git a/docs/release-notes.md b/docs/release-notes.md index 2b7d1545..b425112d 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -12,6 +12,7 @@ These changes have not been released yet. * Now ignores metadata files/folders like `__MACOSX` and `__folder_managed_by_vortex`. * Now ignores content files like `.txt` or `.png`, which avoids missing-manifest errors in some common cases. * Now detects XNB mods more accurately, and consolidates multi-folder XNB mods. + * Save Backup now works in the background, to avoid affecting startup time for players with a large number of saves. * Duplicate-mod errors now show the mod version in each folder. * Updated mod compatibility list. * Fixed mods needing to load custom `Map` assets before the game accesses them (SMAPI will now do so automatically). diff --git a/src/SMAPI.Mods.SaveBackup/ModEntry.cs b/src/SMAPI.Mods.SaveBackup/ModEntry.cs index 33adf76d..845df453 100644 --- a/src/SMAPI.Mods.SaveBackup/ModEntry.cs +++ b/src/SMAPI.Mods.SaveBackup/ModEntry.cs @@ -4,6 +4,7 @@ using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; +using System.Threading.Tasks; using StardewValley; namespace StardewModdingAPI.Mods.SaveBackup @@ -40,9 +41,10 @@ namespace StardewModdingAPI.Mods.SaveBackup DirectoryInfo backupFolder = new DirectoryInfo(this.BackupFolder); backupFolder.Create(); - // back up saves - this.CreateBackup(backupFolder); - this.PruneBackups(backupFolder, this.BackupsToKeep); + // back up & prune saves + Task + .Run(() => this.CreateBackup(backupFolder)) + .ContinueWith(backupTask => this.PruneBackups(backupFolder, this.BackupsToKeep)); } catch (Exception ex) { @@ -68,7 +70,7 @@ namespace StardewModdingAPI.Mods.SaveBackup // create zip // due to limitations with the bundled Mono on Mac, we can't reference System.IO.Compression. - this.Monitor.Log($"Adding {targetFile.Name}...", LogLevel.Trace); + this.Monitor.Log($"Backing up saves to {targetFile.FullName}...", LogLevel.Trace); switch (Constants.TargetPlatform) { case GamePlatform.Linux: @@ -108,6 +110,7 @@ namespace StardewModdingAPI.Mods.SaveBackup } break; } + this.Monitor.Log("Backup done!", LogLevel.Trace); } catch (Exception ex) {