Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tell user if instance addition fails #3332

Merged
merged 1 commit into from
Mar 29, 2021

Conversation

HebaruSan
Copy link
Member

Problem

If a user tries to add a game instance for which they lack filesystem write privileges, it fails silently, and an exception appears in the terminal:

System.UnauthorizedAccessException: Access to the path '/ram/Fake-1.11.1/CKAN' is denied. ---> System.IO.IOException: Keine Berechtigung
--- End of inner exception stack trace ---
at System.IO.FileSystem.CreateDirectory (System.String fullPath) [0x00191] in <673b2a9c49de4736b9b01249f8d6d6b1>:0
at System.IO.Directory.CreateDirectory (System.String path) [0x0002c] in <673b2a9c49de4736b9b01249f8d6d6b1>:0
at ChinhDo.Transactions.FileManager.TxFileManager.CreateDirectory (System.String path) [0x0001b] in <bd256a5f4bd9434c90d5e776dca9de7b>:0
at CKAN.GameInstance.SetupCkanDirectories (System.Boolean scan) [0x0006e] in <bd256a5f4bd9434c90d5e776dca9de7b>:0
at CKAN.GameInstance..ctor (CKAN.Games.IGame game, System.String gameDir, System.String name, CKAN.IUser user, System.Boolean scan) [0x0007e] in <bd256a5f4bd9434c90d5e776dca9de7b>:0
at CKAN.GameInstanceManager.AddInstance (System.String path, System.String name, CKAN.IUser user) [0x00053] in <bd256a5f4bd9434c90d5e776dca9de7b>:0
at CKAN.ManageGameInstancesDialog.AddToCKANMenuItem_Click (System.Object sender, System.EventArgs e) [0x0005f] in <bd256a5f4bd9434c90d5e776dca9de7b>:0

Most users don't look at the terminal, so this is confusing.

Cause

We try to create the <KSP>/CKAN folder, which fails, and we don't catch the exception.

Changes

Now if an exception is thrown when we try to add an instance, we display the exception's Message in an error popup. This way the user should have some clue why it failed.

Also fixed two minor compiler warnings to do with TarInputStream wanting an encoding parameter and a catch block not using a parameter.

Fixes #3330.

@HebaruSan HebaruSan added Bug Something is not working as intended Easy This is easy to fix GUI Issues affecting the interactive GUI Pull request Linux Issues specific for Linux macOS Issues specific for macOS labels Mar 28, 2021
Copy link
Member

@DasSkelett DasSkelett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solves it indeed, thanks a bunch!

@HebaruSan HebaruSan merged commit d724787 into KSP-CKAN:master Mar 29, 2021
@HebaruSan HebaruSan deleted the fix/add-inst-perms branch March 29, 2021 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended Easy This is easy to fix GUI Issues affecting the interactive GUI Linux Issues specific for Linux macOS Issues specific for macOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] GUI fails silently trying to set up a new instance if it doesn't have write permissions
2 participants