From 805f24fc7f34ec200d1a9ed8a57c8d22b8a32675 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Jul 2021 10:58:12 -0500 Subject: detect changes that require reconnect --- src/slskd/Application/Service.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/slskd/Application/Service.cs b/src/slskd/Application/Service.cs index 41097730..81e558a0 100644 --- a/src/slskd/Application/Service.cs +++ b/src/slskd/Application/Service.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) slskd Team. All rights reserved. // // This program is free software: you can redistribute it and/or modify @@ -208,13 +208,12 @@ namespace slskd foreach (var (property, fqn, left, right) in diff) { var requiresRestart = property.CustomAttributes.Any(c => c.AttributeType == typeof(RequiresRestartAttribute)); + var requiresReconnect = property.CustomAttributes.Any(c => c.AttributeType == typeof(RequiresReconnectAttribute)); - Logger.Debug($"{fqn} changed from '{left ?? ""}' to '{right ?? ""}'{(requiresRestart ? "; Restart required to take effect." : string.Empty)}"); + Logger.Debug($"{fqn} changed from '{left ?? ""}' to '{right ?? ""}'{(requiresRestart ? "; Restart required to take effect." : string.Empty)}{(requiresReconnect ? "; Reconnect required to take effect." : string.Empty)}"); - if (requiresRestart) - { - pendingRestart = true; - } + pendingRestart |= requiresRestart; + pendingReconnect |= requiresReconnect; } // determine whether any Soulseek options changed. if so, we need to construct a patch @@ -270,9 +269,9 @@ namespace slskd Logger.Debug("Patching Soulseek options with {Patch}", patch.ToJson()); - pendingReconnect = await SoulseekClient.ReconfigureOptionsAsync(patch); + var reconfigRequiresReconnect = await SoulseekClient.ReconfigureOptionsAsync(patch); - if (pendingReconnect) + if ((Client.State.HasFlag(SoulseekClientStates.Connected) && pendingReconnect) | reconfigRequiresReconnect) { StateMonitor.Set(state => state with { PendingReconnect = true }); Logger.Information("One or more updated Soulseek options requires the client to be disconnected, then reconnected to the network to take effect."); -- cgit v1.2.3