diff options
| author | JP Dillingham <jp@dillingham.me> | 2023-01-08 13:30:10 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-08 13:30:10 -0600 |
| commit | bbbde98f571dc7cd7a0ed35ef7846cc177372920 (patch) | |
| tree | d711d033bf604444519f98d9854b67d412efcacf /src/slskd/Shares | |
| parent | 9bb9c17312742adb65b37fe84bd64e7267defcd8 (diff) | |
| parent | 5133ac9eabc1ddf195002807f97a95ad0ab8d9a0 (diff) | |
| download | slskd-bbbde98f571dc7cd7a0ed35ef7846cc177372920.tar.gz | |
Merge branch 'master' into relay-docs
Diffstat (limited to 'src/slskd/Shares')
| -rw-r--r-- | src/slskd/Shares/API/Controllers/SharesController.cs | 2 | ||||
| -rw-r--r-- | src/slskd/Shares/ShareService.cs | 18 | ||||
| -rw-r--r-- | src/slskd/Shares/SqliteShareRepository.cs | 2 |
3 files changed, 19 insertions, 3 deletions
diff --git a/src/slskd/Shares/API/Controllers/SharesController.cs b/src/slskd/Shares/API/Controllers/SharesController.cs index e4f82848..2144a979 100644 --- a/src/slskd/Shares/API/Controllers/SharesController.cs +++ b/src/slskd/Shares/API/Controllers/SharesController.cs @@ -74,7 +74,7 @@ namespace slskd.Shares.API [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(typeof(Share), 200)] [ProducesResponseType(404)] - public async Task<IActionResult> Get(string id) + public IActionResult Get(string id) { var share = Shares.Hosts.SelectMany(host => host.Shares).FirstOrDefault(share => share.Id == id); 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"); diff --git a/src/slskd/Shares/SqliteShareRepository.cs b/src/slskd/Shares/SqliteShareRepository.cs index a4c4dd4c..f10b55e5 100644 --- a/src/slskd/Shares/SqliteShareRepository.cs +++ b/src/slskd/Shares/SqliteShareRepository.cs @@ -672,7 +672,7 @@ namespace slskd.Shares var msg = "The internal share database has been corrupted or lost, and the application cannot continue to run. Please report this in a GitHub issue here: https://github.com/slskd/slskd/issues"; Log.Fatal(msg); Environment.Exit(1); - throw new ApplicationException(msg); + throw new DataMisalignedException(msg); } } } |
