diff options
| author | JP Dillingham <jp@dillingham.me> | 2025-08-04 18:25:35 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-04 18:25:35 -0500 |
| commit | d9c5aa6df4a140c7b6e2a1dcd6499bcd3091d99e (patch) | |
| tree | 3a68418b876a4f1dbed9c5aabedbd2644ce32277 /src | |
| parent | bdd085700fa57cf8db0230139c8c639bf70d5ab9 (diff) | |
| parent | 219aa156446e2465783cc018510cd9a18e643bb7 (diff) | |
| download | slskd-d9c5aa6df4a140c7b6e2a1dcd6499bcd3091d99e.tar.gz | |
Merge pull request #1411 from slskd/debug-config
Fix bug preventing proper change detection when updating options with an enum type
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Application.cs | 5 | ||||
| -rw-r--r-- | src/slskd/Common/CommonExtensions.cs | 2 | ||||
| -rw-r--r-- | src/slskd/Core/Options.cs | 5 | ||||
| -rw-r--r-- | src/slskd/Program.cs | 2 |
4 files changed, 10 insertions, 4 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index a28d2a2f..e1f8d762 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -1270,6 +1270,8 @@ namespace slskd // shenanigans here could lead to missed updates. await OptionsSyncRoot.WaitAsync(); + Log.Debug("OptionsMonitor OnChange Invoked"); + try { var pendingRestart = false; @@ -1281,9 +1283,12 @@ namespace slskd // don't react to duplicate/no-change events https://github.com/slskd/slskd/issues/126 if (!diff.Any()) { + Log.Debug("Diff of previous and new options is the same; nothing to do"); return; } + Log.Debug("Diff of previous and new options contains {Count} changed properties: {Properties}", diff.Count(), diff.Select(p => p.FQN)); + foreach (var (property, fqn, left, right) in diff) { static bool HasAttribute<T>(PropertyInfo property) => property.CustomAttributes.Any(a => a.AttributeType == typeof(T)); diff --git a/src/slskd/Common/CommonExtensions.cs b/src/slskd/Common/CommonExtensions.cs index 44e3c034..ec76b745 100644 --- a/src/slskd/Common/CommonExtensions.cs +++ b/src/slskd/Common/CommonExtensions.cs @@ -116,7 +116,7 @@ namespace slskd differences.Add((prop, fqn, leftVal, rightVal)); } } - else if (propType.IsPrimitive || Nullable.GetUnderlyingType(propType) != null || new[] { typeof(string), typeof(decimal) }.Contains(propType)) + else if (propType.IsPrimitive || propType.IsEnum || Nullable.GetUnderlyingType(propType) != null || new[] { typeof(string), typeof(decimal) }.Contains(propType)) { if (!Equals(leftVal, rightVal)) { diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 1fed70f5..4d4c1e68 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -36,10 +36,10 @@ namespace slskd using slskd.Relay; using slskd.Shares; using slskd.Validation; - using Soulseek.Diagnostics; using Utility.CommandLine; using Utility.EnvironmentVariables; using YamlDotNet.Serialization; + using SoulseekDiagnostics = Soulseek.Diagnostics; /// <summary> /// Disambiguates options derived at startup from options that may update at run time. @@ -1572,8 +1572,9 @@ namespace slskd [Argument(default, "slsk-diag-level")] [EnvironmentVariable("SLSK_DIAG_LEVEL")] [Description("minimum diagnostic level (None, Warning, Info, Debug)")] + [Enum(typeof(SoulseekDiagnostics.DiagnosticLevel))] [RequiresRestart] - public DiagnosticLevel DiagnosticLevel { get; init; } = DiagnosticLevel.Info; + public string DiagnosticLevel { get; init; } = SoulseekDiagnostics.DiagnosticLevel.Info.ToString().ToLowerInvariant(); /// <summary> /// Gets options for the distributed network. diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 89230e2a..645e395c 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -584,7 +584,7 @@ namespace slskd new SoulseekClient(options: new SoulseekClientOptions( maximumConcurrentUploads: OptionsAtStartup.Global.Upload.Slots, maximumConcurrentDownloads: OptionsAtStartup.Global.Download.Slots, - minimumDiagnosticLevel: OptionsAtStartup.Soulseek.DiagnosticLevel))); + minimumDiagnosticLevel: OptionsAtStartup.Soulseek.DiagnosticLevel.ToEnum<Soulseek.Diagnostics.DiagnosticLevel>()))); // add the core application service to DI as well as a hosted service so that other services can // access instance methods |
