diff options
| author | JP Dillingham <jp@dillingham.me> | 2024-01-11 22:17:06 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2024-01-11 22:17:06 -0600 |
| commit | 66ac937336d6e1dce0f2c20f4d603933dd718326 (patch) | |
| tree | 1c6d50993fddd4a62afc0c51a8a6db79d28f67ee /src | |
| parent | ce0dfefb9bcaf6f7752d55cd544a17257e67aee6 (diff) | |
| download | slskd-66ac937336d6e1dce0f2c20f4d603933dd718326.tar.gz | |
return file size when resolving
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Shares/IShareService.cs | 4 | ||||
| -rw-r--r-- | src/slskd/Shares/ShareService.cs | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/slskd/Shares/IShareService.cs b/src/slskd/Shares/IShareService.cs index 7e1352e9..7db9671b 100644 --- a/src/slskd/Shares/IShareService.cs +++ b/src/slskd/Shares/IShareService.cs @@ -88,7 +88,7 @@ namespace slskd.Shares void RequestScan(); /// <summary> - /// Resolves the local filename of the specified <paramref name="remoteFilename"/>, if the mask is associated with a + /// Resolves the local filename and size of the specified <paramref name="remoteFilename"/>, if the mask is associated with a /// configured share. /// </summary> /// <param name="remoteFilename">The fully qualified filename to resolve.</param> @@ -96,7 +96,7 @@ namespace slskd.Shares /// <exception cref="NotFoundException"> /// Thrown when the specified remote filename can not be associated with a configured share. /// </exception> - Task<(string Host, string Filename)> ResolveFileAsync(string remoteFilename); + Task<(string Host, string Filename, long Size)> ResolveFileAsync(string remoteFilename); /// <summary> /// Scans the configured shares on the local host. diff --git a/src/slskd/Shares/ShareService.cs b/src/slskd/Shares/ShareService.cs index 97867cde..4f409705 100644 --- a/src/slskd/Shares/ShareService.cs +++ b/src/slskd/Shares/ShareService.cs @@ -267,9 +267,9 @@ namespace slskd.Shares /// <exception cref="NotFoundException"> /// Thrown when the specified remote filename can not be associated with a configured share. /// </exception> - public Task<(string Host, string Filename)> ResolveFileAsync(string remoteFilename) + public Task<(string Host, string Filename, long Size)> ResolveFileAsync(string remoteFilename) { - string resolvedFilename = Local.Repository.FindFilename(remoteFilename); + var (resolvedFilename, size) = Local.Repository.FindFileInfo(remoteFilename); // 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 @@ -281,7 +281,7 @@ namespace slskd.Shares else if (!string.IsNullOrEmpty(resolvedFilename)) { Log.Debug("Resolved remote file to {ResolvedFilename} on local host", resolvedFilename); - return Task.FromResult((Program.LocalHostName, resolvedFilename)); + return Task.FromResult((Program.LocalHostName, resolvedFilename, size)); } else { @@ -292,12 +292,12 @@ namespace slskd.Shares // this is the slow, dumb way to do this, but it's plenty fast in this context. foreach (var host in HostDictionary.Values) { - resolvedFilename = host.Repository.FindFilename(remoteFilename); + (resolvedFilename, size) = host.Repository.FindFileInfo(remoteFilename); 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)); + return Task.FromResult((host.Host.Name, resolvedFilename, size)); } Log.Debug("Failed to resolve remote file on host {Host}", host.Host.Name); |
