fix install error on Linux/Mac in some cases

This commit is contained in:
Jesse Plamondon-Willard 2018-05-04 20:54:15 -04:00
parent 8051862c7b
commit a65a49a622
2 changed files with 11 additions and 8 deletions

View File

@ -8,6 +8,7 @@
* Added console warning for mods which don't have update checks configured.
* Fixed console color scheme on Mac or in PowerShell, configurable via `StardewModdingAPI.config.json`.
* Fixed detection of GOG Galaxy install path in rare cases.
* Fixed install error on Linux/Mac in some cases.
* For modders:
* Added code analysis to mod build config package to flag common issues as warnings.

View File

@ -233,7 +233,7 @@ namespace StardewModdingApi.Installer
Console.ReadLine();
return;
}
if (!this.HasXNA(platform))
if (!this.HasXna(platform))
{
this.PrintError("You don't seem to have XNA Framework installed. Please run the game at least once before installing SMAPI, so it can perform its first-time setup.");
Console.ReadLine();
@ -317,10 +317,13 @@ namespace StardewModdingApi.Installer
if (platform.IsMono())
{
this.PrintDebug("Safely replacing game launcher...");
if (File.Exists(paths.unixLauncher))
{
if (!File.Exists(paths.unixLauncherBackup))
File.Move(paths.unixLauncher, paths.unixLauncherBackup);
else if (File.Exists(paths.unixLauncher))
else
this.InteractivelyDelete(paths.unixLauncher);
}
File.Move(paths.unixSmapiLauncher, paths.unixLauncher);
}
@ -471,7 +474,7 @@ namespace StardewModdingApi.Installer
/// <summary>Get whether the current system has XNA Framework installed. This only applies on Windows.</summary>
/// <param name="platform">The current platform.</param>
/// <exception cref="NotSupportedException">The current platform is not Windows.</exception>
private bool HasXNA(Platform platform)
private bool HasXna(Platform platform)
{
switch (platform)
{
@ -514,8 +517,7 @@ namespace StardewModdingApi.Installer
return;
// delete children
var folder = entry as DirectoryInfo;
if (folder != null)
if (entry is DirectoryInfo folder)
{
foreach (FileSystemInfo child in folder.GetFileSystemInfos())
this.ForceDelete(child);