From 66ac937336d6e1dce0f2c20f4d603933dd718326 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 11 Jan 2024 22:17:06 -0600 Subject: return file size when resolving --- src/slskd/Shares/IShareService.cs | 4 ++-- src/slskd/Shares/ShareService.cs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') 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(); /// - /// Resolves the local filename of the specified , if the mask is associated with a + /// Resolves the local filename and size of the specified , if the mask is associated with a /// configured share. /// /// The fully qualified filename to resolve. @@ -96,7 +96,7 @@ namespace slskd.Shares /// /// Thrown when the specified remote filename can not be associated with a configured share. /// - Task<(string Host, string Filename)> ResolveFileAsync(string remoteFilename); + Task<(string Host, string Filename, long Size)> ResolveFileAsync(string remoteFilename); /// /// 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 /// /// Thrown when the specified remote filename can not be associated with a configured share. /// - 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); -- cgit v1.2.3