Skip to content

Commit

Permalink
Fix a hard crash happening when UniGetUI in portable mode does not ha…
Browse files Browse the repository at this point in the history
…ve write permissions on the settings directory
  • Loading branch information
marticliment committed Feb 8, 2025
1 parent 1d9e025 commit 104de8d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/UniGetUI.Core.Data/CoreData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,22 @@ public static string UniGetUIDataDirectory
if (IS_PORTABLE is null)
IS_PORTABLE = File.Exists(Path.Join(UniGetUIExecutableDirectory, "ForceUniGetUIPortable"));

if (IS_PORTABLE == true)
if (IS_PORTABLE is true)
{
string path = Path.Join(UniGetUIExecutableDirectory, "Settings");
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
return path;
try
{
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
var testfilepath = Path.Join(path, "PermissionTestFile");
File.WriteAllText(testfilepath, "https://www.youtube.com/watch?v=dQw4w9WgXcQ");
return path;
}
catch (Exception ex)
{
IS_PORTABLE = false;
Logger.Error($"Could not acces/write path {path}. UniGetUI will NOT be run in portable mode, and User settings will be used instead");
Logger.Error(ex);
}
}

string old_path = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".wingetui");
Expand Down

0 comments on commit 104de8d

Please sign in to comment.