From fc9043c1ba80bc7d593ca9f00659b866d99e2251 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 26 Nov 2017 16:58:41 -0500 Subject: fix rare installer error on Mac due to generated mcs file (#394) --- src/SMAPI.Installer/InteractiveInstaller.cs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/SMAPI.Installer/InteractiveInstaller.cs') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index b5c2735b..83f353ae 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -296,7 +296,7 @@ namespace StardewModdingApi.Installer { // copy SMAPI files to game dir this.PrintDebug("Adding SMAPI files..."); - foreach (FileInfo sourceFile in packageDir.EnumerateFiles()) + foreach (FileInfo sourceFile in packageDir.EnumerateFiles().Where(this.ShouldCopyFile)) { string targetPath = Path.Combine(installDir.FullName, sourceFile.Name); this.InteractivelyDelete(targetPath); @@ -338,7 +338,7 @@ namespace StardewModdingApi.Installer targetDir.Create(); // copy files - foreach (FileInfo sourceFile in sourceDir.EnumerateFiles()) + foreach (FileInfo sourceFile in sourceDir.EnumerateFiles().Where(this.ShouldCopyFile)) sourceFile.CopyTo(Path.Combine(targetDir.FullName, sourceFile.Name)); } } @@ -684,7 +684,7 @@ namespace StardewModdingApi.Installer this.PrintDebug(" Support for mods here was dropped in SMAPI 1.0 (it was never officially supported)."); // move mods if no conflicts (else warn) - foreach (FileSystemInfo entry in modDir.EnumerateFileSystemInfos()) + foreach (FileSystemInfo entry in modDir.EnumerateFileSystemInfos().Where(this.ShouldCopyFile)) { // get type bool isDir = entry is DirectoryInfo; @@ -718,7 +718,7 @@ namespace StardewModdingApi.Installer else { this.PrintDebug(" Deleted empty directory."); - modDir.Delete(); + modDir.Delete(recursive: true); } } @@ -741,11 +741,22 @@ namespace StardewModdingApi.Installer Directory.CreateDirectory(newPath); DirectoryInfo directory = (DirectoryInfo)entry; - foreach (FileSystemInfo child in directory.EnumerateFileSystemInfos()) + foreach (FileSystemInfo child in directory.EnumerateFileSystemInfos().Where(this.ShouldCopyFile)) this.Move(child, Path.Combine(newPath, child.Name)); - directory.Delete(); + directory.Delete(recursive: true); } } + + /// Get whether a file should be copied when moving a folder. + /// The file info. + private bool ShouldCopyFile(FileSystemInfo file) + { + // ignore Mac symlink + if (file is FileInfo && file.Name == "mcs") + return false; + + return true; + } } } -- cgit