diff options
| author | JP Dillingham <jp@dillingham.me> | 2023-01-07 18:54:29 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-07 18:54:29 -0600 |
| commit | ff5f0ac6c93f2b49ba259e7093fb92fa873116c6 (patch) | |
| tree | 89a57703213c524f09346aac4fcf3a9ee8b3cf04 /src/slskd/Shares | |
| parent | d5eabb72a5c5a3aed06f0c4b8f66c853468b889b (diff) | |
| parent | f07a7758b47388c793d73ca54727db95abfcd229 (diff) | |
| download | slskd-ff5f0ac6c93f2b49ba259e7093fb92fa873116c6.tar.gz | |
Merge pull request #827 from slskd/relay-debug
Miscellaneous Relay refactoring and bugfixes
Diffstat (limited to 'src/slskd/Shares')
| -rw-r--r-- | src/slskd/Shares/ShareService.cs | 18 |
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"); |
