diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-07 22:17:38 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-07 22:17:38 -0500 |
commit | 860ccb90f790807c0f551e10dfff3ae03279d965 (patch) | |
tree | faa1af0f0efc466ea1bb0fd617fb05e505bd8b27 /src | |
parent | 2c11ce1bff5da9820b3207ad1aa83ac7350741b9 (diff) | |
download | SMAPI-860ccb90f790807c0f551e10dfff3ae03279d965.tar.gz SMAPI-860ccb90f790807c0f551e10dfff3ae03279d965.tar.bz2 SMAPI-860ccb90f790807c0f551e10dfff3ae03279d965.zip |
fix the installer not removing TrainerMod from appdata if it's already in the game mods folder
Diffstat (limited to 'src')
-rw-r--r-- | src/StardewModdingAPI.Installer/InteractiveInstaller.cs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs index d7bf7b0e..cfd64458 100644 --- a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs +++ b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs @@ -89,7 +89,6 @@ namespace StardewModdingApi.Installer unixLauncher = Path.Combine(installDir.FullName, "StardewValley"), unixLauncherBackup = Path.Combine(installDir.FullName, "StardewValley-original") }; - this.PrintDebug($"Detected {(platform == Platform.Windows ? "Windows" : "Linux or Mac")} with game in {installDir}."); /**** @@ -221,7 +220,7 @@ namespace StardewModdingApi.Installer } // remove obsolete appdata mods - this.InteractivelyRemoveAppDataMods(platform, modsDir); + this.InteractivelyRemoveAppDataMods(platform, modsDir, packagedModsDir); } Console.WriteLine(); @@ -362,8 +361,12 @@ namespace StardewModdingApi.Installer /// <summary>Interactively move mods out of the appdata directory.</summary> /// <param name="platform">The current platform.</param> /// <param name="properModsDir">The directory which should contain all mods.</param> - private void InteractivelyRemoveAppDataMods(Platform platform, DirectoryInfo properModsDir) + /// <param name="packagedModsDir">The installer directory containing packaged mods.</param> + private void InteractivelyRemoveAppDataMods(Platform platform, DirectoryInfo properModsDir, DirectoryInfo packagedModsDir) { + // get packaged mods to delete + string[] packagedModNames = packagedModsDir.GetDirectories().Select(p => p.Name).ToArray(); + // get path string homePath = platform == Platform.Windows ? Environment.GetEnvironmentVariable("APPDATA") @@ -385,6 +388,14 @@ namespace StardewModdingApi.Installer if (!isDir && !(entry is FileInfo)) continue; // should never happen + // delete packaged mods (newer version bundled into SMAPI) + if (isDir && packagedModNames.Contains(entry.Name, StringComparer.InvariantCultureIgnoreCase)) + { + this.PrintDebug($" Deleting {entry.Name} because it's bundled into SMAPI..."); + entry.Delete(); + continue; + } + // check paths string newPath = Path.Combine(properModsDir.FullName, entry.Name); if (isDir ? Directory.Exists(newPath) : File.Exists(newPath)) |