NetSparkleUpdater / NetSparkle

NetSparkle is a C# cross-platform software update framework for .NET developers compatible with .NET 4.6.2/.NET 6+, WinForms, WPF, and Avalonia; uses Ed25519 or DSA signatures! View basic usage here in the README or visit our website for code docs.
https://netsparkleupdater.github.io/NetSparkle/
MIT License
585 stars 81 forks source link

[MacOS] App crash when unable to write Configuration file #582

Closed SiMet closed 3 weeks ago

SiMet commented 3 weeks ago

We faced application crash on MacOS when user does not have access to .config directory. There is an exception System.UnauthorizedAccessException Access to the path '/Users/silentum/.config/MyCoolApp/MyCoolApp/NetSparkleUpdater' is denied.

To reproduce this issue I removed .config and then created it as root with chmod 0707.

In our code we do StartLoop(true, true, TimeSpan.FromMinutes(30)) on SparkleUpdater object

We susspect that this is because async void OnWorkerDoWork is throwing exception and we are unable to catch it. (change to async Task could solve this issue). There is also no catch for System.IO exception in JSONConfiguration.GetSavePath when creating directory which could prevent this crash.

Crash call stack:

JSONConfiguration.cs in string JSONConfiguration.GetSavePath() at line 122
JSONConfiguration.cs in new JSONConfiguration(IAssemblyAccessor assemblyAccessor, string savePath) x 2 at line 51
SparkleUpdater.cs in Configuration SparkleUpdater.get_Configuration() at line 258
SparkleUpdater.cs in async void SparkleUpdater.OnWorkerDoWork(object sender, DoWorkEventArgs e) at line 1921
SiMet commented 3 weeks ago

Related: https://github.com/NetSparkleUpdater/NetSparkle/issues/397

Deadpikle commented 3 weeks ago

@SiMet,

Thank you for the report.

397 is not related.

You may want to consider upgrading to .NET 8, as at that time they updated the folder that Environment.SpecialFolder.ApplicationData points to (see docs here), which should be more reliable.

That being said, I have: