diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-07-09 23:03:22 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-07-09 23:03:22 -0400 |
commit | 357b392ca239d1cc9000dbf9283f431a32d4c36d (patch) | |
tree | 9644b6883ae49acf03b0b2742c8718deb03e755c /src/SMAPI.Installer/InteractiveInstaller.cs | |
parent | 4f854aea1530177f959fc01b1731ae4759830321 (diff) | |
download | SMAPI-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.cs | 21 |
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)) |