diff options
| author | copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> | 2025-12-07 00:16:04 +0000 |
|---|---|---|
| committer | copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> | 2025-12-07 00:16:04 +0000 |
| commit | 1d09aef10a03fb4263a0e312c979d5a153fc9b31 (patch) | |
| tree | 069ad4c47df3e81d0ee4cfd7b80bd25e07246bfd /src/slskd/Program.cs | |
| parent | 736970deaf13b14ed7141558faee56f7200ab62a (diff) | |
| download | slskd-1d09aef10a03fb4263a0e312c979d5a153fc9b31.tar.gz | |
Address code review feedback: use specific exceptions and dispose Mutex
Co-authored-by: jpdillingham <17145758+jpdillingham@users.noreply.github.com>
Diffstat (limited to 'src/slskd/Program.cs')
| -rw-r--r-- | src/slskd/Program.cs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index c51d07d8..29783216 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -345,12 +345,18 @@ namespace slskd return; } } - catch (Exception ex) + catch (IOException ex) { Log.Fatal($"Failed to acquire the application singleton mutex: {ex.Message}"); Log.Warning("This can happen when running in a restricted environment (e.g., Kubernetes with readOnlyRootFilesystem)"); Log.Warning("The application will continue, but multiple instances may be able to run simultaneously"); } + catch (UnauthorizedAccessException ex) + { + Log.Fatal($"Failed to acquire the application singleton mutex: {ex.Message}"); + Log.Warning("This can happen when running with insufficient permissions"); + Log.Warning("The application will continue, but multiple instances may be able to run simultaneously"); + } // derive the application directory value and defaults that are dependent upon it AppDirectory ??= DefaultAppDirectory; @@ -551,6 +557,7 @@ namespace slskd } finally { + Mutex?.Dispose(); Serilog.Log.CloseAndFlush(); } } |
