diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index fbdb797..3c036db 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -182,7 +182,7 @@ namespace Bloxstrap { Logger.Initialize(LaunchSettings.IsUninstall); - if (!Logger.Initialized) + if (!Logger.Initialized && !Logger.NoWriteMode) { Logger.WriteLine(LOG_IDENT, "Possible duplicate launch detected, terminating."); Terminate(); diff --git a/Bloxstrap/Logger.cs b/Bloxstrap/Logger.cs index 9bea80a..344d55a 100644 --- a/Bloxstrap/Logger.cs +++ b/Bloxstrap/Logger.cs @@ -9,6 +9,7 @@ public readonly List Backlog = new(); public bool Initialized = false; + public bool NoWriteMode = false; public string? FileLocation; public void Initialize(bool useTempDir = false) @@ -45,6 +46,23 @@ WriteLine(LOG_IDENT, "Failed to initialize because log file already exists"); return; } + catch (UnauthorizedAccessException) + { + if (NoWriteMode) + return; + + WriteLine(LOG_IDENT, $"Failed to initialize because Bloxstrap cannot write to {directory}"); + + Frontend.ShowMessageBox( + String.Format(Resources.Strings.Logger_NoWriteMode, directory), + System.Windows.MessageBoxImage.Warning, + System.Windows.MessageBoxButton.OK + ); + + NoWriteMode = true; + + return; + } Initialized = true; diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index 778c6da..ed949f4 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -1317,6 +1317,15 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to No log file will be written for this launch because Bloxstrap is unable to write to the folder at '{0}'. + /// + public static string Logger_NoWriteMode { + get { + return ResourceManager.GetString("Logger.NoWriteMode", resourceCulture); + } + } + /// /// Looks up a localized string similar to Contributors. /// diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index b06882f..f7c0682 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -1079,4 +1079,7 @@ Selecting 'No' will ignore this warning and continue installation. The entry for '{0}' is not valid as the value must be a number + + No log file will be written for this launch because Bloxstrap is unable to write to the folder at '{0}' + \ No newline at end of file