aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-07-23 10:58:12 -0500
committerJP Dillingham <jpdillingham@gmail.com>2021-07-23 10:58:12 -0500
commit805f24fc7f34ec200d1a9ed8a57c8d22b8a32675 (patch)
treeac4e390501b52fe702e3c79c8a45bf25ee042b31
parent06a324feff453f7dcc817b7b964ac7547f658e34 (diff)
downloadslskd-805f24fc7f34ec200d1a9ed8a57c8d22b8a32675.tar.gz
detect changes that require reconnect
-rw-r--r--src/slskd/Application/Service.cs15
1 files changed, 7 insertions, 8 deletions
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 file="Service.cs" company="slskd Team">
+// <copyright file="Service.cs" company="slskd Team">
// 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 ?? "<null>"}' to '{right ?? "<null>"}'{(requiresRestart ? "; Restart required to take effect." : string.Empty)}");
+ Logger.Debug($"{fqn} changed from '{left ?? "<null>"}' to '{right ?? "<null>"}'{(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.");