From 860ccb90f790807c0f551e10dfff3ae03279d965 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 7 Dec 2016 22:17:38 -0500 Subject: fix the installer not removing TrainerMod from appdata if it's already in the game mods folder --- src/StardewModdingAPI.Installer/InteractiveInstaller.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src') 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 /// Interactively move mods out of the appdata directory. /// The current platform. /// The directory which should contain all mods. - private void InteractivelyRemoveAppDataMods(Platform platform, DirectoryInfo properModsDir) + /// The installer directory containing packaged mods. + 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)) -- cgit