summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-07-29 13:15:27 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-09-14 18:59:23 -0400
commit2b4bc2c282e17ba431f9a6ec1892b87a37eb4bb7 (patch)
tree90897a0eeeabe59ae415841a932ffaee971a35b1 /src
parent95f261b1f30d8c5ad6c179cd75a220dcca3c6395 (diff)
downloadSMAPI-2b4bc2c282e17ba431f9a6ec1892b87a37eb4bb7.tar.gz
SMAPI-2b4bc2c282e17ba431f9a6ec1892b87a37eb4bb7.tar.bz2
SMAPI-2b4bc2c282e17ba431f9a6ec1892b87a37eb4bb7.zip
back up saves in a background thread
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Mods.SaveBackup/ModEntry.cs11
1 files changed, 7 insertions, 4 deletions
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)
{