summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2016-12-07 22:43:05 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2016-12-07 22:43:05 -0500
commitae44f17205961116baef018bae0b8fe9196b27f0 (patch)
treecc4bde5ebfec071ad2dd3f60db0b78bcc39a1602
parent860ccb90f790807c0f551e10dfff3ae03279d965 (diff)
downloadSMAPI-ae44f17205961116baef018bae0b8fe9196b27f0.tar.gz
SMAPI-ae44f17205961116baef018bae0b8fe9196b27f0.tar.bz2
SMAPI-ae44f17205961116baef018bae0b8fe9196b27f0.zip
fix installer not moving mods out of appdata if the game isn't installed on the same Windows partition (#184)
-rw-r--r--release-notes.md3
-rw-r--r--src/StardewModdingAPI.Installer/InteractiveInstaller.cs32
2 files changed, 30 insertions, 5 deletions
diff --git a/release-notes.md b/release-notes.md
index 133ae929..e7712011 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -7,7 +7,8 @@ For players:
* Installing SMAPI will now automatically clean up old SMAPI files.
* Each mod now has its own `.cache` folder, so removing the mod won't leave orphaned cache files behind.
* Tweaked installer wording to avoid confusion.
- * Fixed the installer not removing TrainerMod from the legacy appdata mods directory if it's already present in the game mods directory.
+ * Fixed the installer not removing TrainerMod from appdata if it's already in the game mods directory.
+ * Fixed the installer not moving mods out of appdata if the game isn't installed on the same Windows partition.
For developers:
* Added a searchable `list_items` command to replace the `out_items`, `out_melee`, and `out_rings` commands.
diff --git a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
index cfd64458..ffdef37b 100644
--- a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
+++ b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
@@ -406,10 +406,7 @@ namespace StardewModdingApi.Installer
// move into mods
this.PrintDebug($" Moving {entry.Name} into the game's mod directory...");
- if (isDir)
- (entry as DirectoryInfo).MoveTo(newPath);
- else
- (entry as FileInfo).MoveTo(newPath);
+ this.Move(entry, newPath);
}
// delete if empty
@@ -421,5 +418,32 @@ namespace StardewModdingApi.Installer
modDir.Delete();
}
}
+
+ /// <summary>Move a filesystem entry to a new parent directory.</summary>
+ /// <param name="entry">The filesystem entry to move.</param>
+ /// <param name="newPath">The destination path.</param>
+ /// <remarks>We can't use <see cref="FileInfo.MoveTo"/> or <see cref="DirectoryInfo.MoveTo"/>, because those don't work across partitions.</remarks>
+ private void Move(FileSystemInfo entry, string newPath)
+ {
+ // file
+ if (entry is FileInfo)
+ {
+ FileInfo file = (FileInfo)entry;
+ file.CopyTo(newPath);
+ file.Delete();
+ }
+
+ // directory
+ else
+ {
+ Directory.CreateDirectory(newPath);
+
+ DirectoryInfo directory = (DirectoryInfo)entry;
+ foreach (FileSystemInfo child in directory.EnumerateFileSystemInfos())
+ this.Move(child, Path.Combine(newPath, child.Name));
+
+ directory.Delete();
+ }
+ }
}
}