summaryrefslogtreecommitdiff
path: root/src/SMAPI.Installer/InteractiveInstaller.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-07-09 23:03:22 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-07-09 23:03:22 -0400
commit357b392ca239d1cc9000dbf9283f431a32d4c36d (patch)
tree9644b6883ae49acf03b0b2742c8718deb03e755c /src/SMAPI.Installer/InteractiveInstaller.cs
parent4f854aea1530177f959fc01b1731ae4759830321 (diff)
downloadSMAPI-357b392ca239d1cc9000dbf9283f431a32d4c36d.tar.gz
SMAPI-357b392ca239d1cc9000dbf9283f431a32d4c36d.tar.bz2
SMAPI-357b392ca239d1cc9000dbf9283f431a32d4c36d.zip
fix installer removing SaveBackup's config.json and previous backups
Diffstat (limited to 'src/SMAPI.Installer/InteractiveInstaller.cs')
-rw-r--r--src/SMAPI.Installer/InteractiveInstaller.cs21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs
index 1221f659..a5d5055f 100644
--- a/src/SMAPI.Installer/InteractiveInstaller.cs
+++ b/src/SMAPI.Installer/InteractiveInstaller.cs
@@ -21,6 +21,12 @@ namespace StardewModdingApi.Installer
/// <summary>The name of the installer file in the package.</summary>
private readonly string InstallerFileName = "install.exe";
+ /// <summary>Mod files which shouldn't be deleted when deploying bundled mods (mod folder name => file names).</summary>
+ private readonly IDictionary<string, HashSet<string>> ProtectBundledFiles = new Dictionary<string, HashSet<string>>(StringComparer.InvariantCultureIgnoreCase)
+ {
+ ["SaveBackup"] = new HashSet<string>(new[] { "backups", "config.json" }, StringComparer.InvariantCultureIgnoreCase)
+ };
+
/// <summary>The <see cref="Environment.OSVersion"/> value that represents Windows 7.</summary>
private readonly Version Windows7Version = new Version(6, 1);
@@ -386,10 +392,19 @@ namespace StardewModdingApi.Installer
{
this.PrintDebug($" adding {sourceDir.Name}...");
- // initialise target dir
+ // init/clear target dir
DirectoryInfo targetDir = new DirectoryInfo(Path.Combine(modsDir.FullName, sourceDir.Name));
- this.InteractivelyDelete(targetDir.FullName);
- targetDir.Create();
+ if (targetDir.Exists)
+ {
+ this.ProtectBundledFiles.TryGetValue(targetDir.Name, out HashSet<string> protectedFiles);
+ foreach (FileSystemInfo entry in targetDir.EnumerateFileSystemInfos())
+ {
+ if (protectedFiles == null || !protectedFiles.Contains(entry.Name))
+ this.InteractivelyDelete(entry.FullName);
+ }
+ }
+ else
+ targetDir.Create();
// copy files
foreach (FileInfo sourceFile in sourceDir.EnumerateFiles().Where(this.ShouldCopyFile))