aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2023-01-07 10:29:23 -0600
committerJP Dillingham <jp@dillingham.me>2023-01-07 10:29:23 -0600
commit3ce9de999597db6ae742722c86a7179c5d3282e7 (patch)
treea4805332ed167643929f3a0747fc5a9d04ac4b6f /src
parentee01ea15c674882b4e79da9c0364727f1e86c965 (diff)
downloadslskd-3ce9de999597db6ae742722c86a7179c5d3282e7.tar.gz
solve for relay debugging in file resolution logic
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Shares/ShareService.cs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/slskd/Shares/ShareService.cs b/src/slskd/Shares/ShareService.cs
index 8f78ed55..bdc18859 100644
--- a/src/slskd/Shares/ShareService.cs
+++ b/src/slskd/Shares/ShareService.cs
@@ -26,6 +26,7 @@ namespace slskd.Shares
using System.Threading;
using System.Threading.Tasks;
using Serilog;
+ using slskd.Relay;
using Soulseek;
/// <summary>
@@ -269,10 +270,22 @@ namespace slskd.Shares
{
string resolvedFilename = Local.Repository.FindFilename(remoteFilename);
- if (!string.IsNullOrEmpty(resolvedFilename))
+ // when we're debugging the relay (running as both controller and agent on the same instance)
+ // always resolve files from remote hosts, ignoring local. this is a crappy hack, but it is the
+ // least crappy way to maintain sanity while trying to debug this feature.
+ if (OptionsMonitor.CurrentValue.Relay.Mode.ToEnum<RelayMode>() == RelayMode.Debug)
{
+ Log.Warning("Ignoring resolved local file to facilitate Relay debugging.");
+ }
+ else if (!string.IsNullOrEmpty(resolvedFilename))
+ {
+ Log.Debug("Resolved remote file to {ResolvedFilename} on local host", resolvedFilename);
return Task.FromResult((Program.LocalHostName, resolvedFilename));
}
+ else
+ {
+ Log.Debug("Failed to resolve remote file on local host; searching remote hosts: {Hosts}", HostDictionary.Values.Select(h => h.Host.Name));
+ }
// file not found locally. begin searching other hosts one by one.
// this is the slow, dumb way to do this, but it's plenty fast in this context.
@@ -282,8 +295,11 @@ namespace slskd.Shares
if (!string.IsNullOrEmpty(resolvedFilename))
{
+ Log.Debug("Resolved remote file to {ResolvedFilename} on host {Host}", remoteFilename, host.Host.Name);
return Task.FromResult((host.Host.Name, resolvedFilename));
}
+
+ Log.Debug("Failed to resolve remote file on host {Host}", host.Host.Name);
}
throw new NotFoundException($"The requested filename '{remoteFilename}' could not be resolved to a physical file");