Skip to content

Commit

Permalink
Added: some guidance in case installer fails to write shortcut.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Nov 29, 2024
1 parent 8e01595 commit d1f32db
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions source/Reloaded.Mod.Installer.Lib/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ await CheckAndInstallMissingRuntimesAsync(settings.InstallLocation, tempDownload
IOEx.TryDeleteDirectory(settings.InstallLocation);
Native.MessageBox(IntPtr.Zero, "There was an error in installing Reloaded.\n" +
$"Feel free to open an issue on github.com/Reloaded-Project/Reloaded-II if you require support.\n" +
$"Exception: {e}\n" +
$"Message: {e.Message}\n" +
$"Inner Exception: {e.InnerException}\n" +
$"Stack Trace: {e.StackTrace}", "Error in Installing Reloaded", MB_OK);
}
}
Expand All @@ -163,16 +165,32 @@ [Desktop Entry]
desktopFile = desktopFile.Replace("{NATIVEPATH}", nativeExecutablePath);
shortcutPath = shortcutPath.Replace(".lnk", ".desktop");
shortcutPath = SanitizeFileName(shortcutPath);

File.WriteAllText(shortcutPath, desktopFile);

// Write `.desktop` file that integrates into shell.
var shellShortcutPath = $@"Z:\home\{userName}\.local\share\applications\{Path.GetFileName(shortcutPath)}";
File.WriteAllText(shellShortcutPath, desktopFile);

// Mark as executable.
LinuxTryMarkAsExecutable(shortcutPath);
LinuxTryMarkAsExecutable(shellShortcutPath);
try
{
File.WriteAllText(shortcutPath, desktopFile);

// Write `.desktop` file that integrates into shell.
var shellShortcutPath = $@"Z:\home\{userName}\.local\share\applications\{Path.GetFileName(shortcutPath)}";
File.WriteAllText(shellShortcutPath, desktopFile);

// Mark as executable.
LinuxTryMarkAsExecutable(shortcutPath);
LinuxTryMarkAsExecutable(shellShortcutPath);
}
catch (FileNotFoundException e)
{
ThrowFailedToCreateShortcut(e);
}
catch (DirectoryNotFoundException e)
{
ThrowFailedToCreateShortcut(e);
}
void ThrowFailedToCreateShortcut(Exception e)
{
throw new Exception("Failed to create Reloaded shortcut.\n" +
"If you have `protontricks` installed via `flatpak`, you may need to give it FileSystem permission `flatpak override --user --filesystem=host com.github.Matoking.protontricks`", e);
}
}

private static void LinuxTryMarkAsExecutable(string windowsPath)
Expand Down

0 comments on commit d1f32db

Please sign in to comment.