aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2024-12-17 17:51:12 -0600
committerGitHub <noreply@github.com>2024-12-17 17:51:12 -0600
commit10393094e835755d3dacf5255b3598b5868bbc49 (patch)
treec643808170ed05801c2077cd330a7898fbdf8b9c /src
parentac4518147eebd921edb7cf465013eabc37fae4e7 (diff)
parent4f09ab6662c709d6b5eb0bacf8f24af56c3bff37 (diff)
downloadslskd-10393094e835755d3dacf5255b3598b5868bbc49.tar.gz
Merge pull request #1260 from slskd/quick-relay-info
Add OptimisticRelayFileInfo flag to (potentially) speed up enqueue of files hosted on a Relay agent
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Core/Options.cs9
-rw-r--r--src/slskd/Transfers/Uploads/UploadService.cs19
2 files changed, 22 insertions, 6 deletions
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs
index a7fb26c4..32188aef 100644
--- a/src/slskd/Core/Options.cs
+++ b/src/slskd/Core/Options.cs
@@ -435,6 +435,15 @@ namespace slskd
[EnvironmentVariable("LEGACY_WINDOWS_TCP_KEEPALIVE")]
[Description("use a legacy TCP keepalive strategy for older Windows versions")]
public bool LegacyWindowsTcpKeepalive { get; init; } = false;
+
+ /// <summary>
+ /// Gets a value indicating whether to use the uploaded shares from Relay agents as the source of
+ /// truth for file existence and size, instead of querying the agent prior to enqueueing the file.
+ /// </summary>
+ [Argument(default, "optimistic-relay-file-info")]
+ [EnvironmentVariable("OPTIMISTIC_RELAY_FILE_INFO")]
+ [Description("use uploaded relay shares as source of truth for file existence and size")]
+ public bool OptimisticRelayFileInfo { get; init; } = false;
}
/// <summary>
diff --git a/src/slskd/Transfers/Uploads/UploadService.cs b/src/slskd/Transfers/Uploads/UploadService.cs
index fa9a3359..dff1252b 100644
--- a/src/slskd/Transfers/Uploads/UploadService.cs
+++ b/src/slskd/Transfers/Uploads/UploadService.cs
@@ -232,15 +232,22 @@ namespace slskd.Transfers.Uploads
}
else
{
- var (exists, length) = await Relay.GetFileInfoAsync(agentName: host, filename);
-
- if (!exists || length <= 0)
+ if (OptionsMonitor.CurrentValue.Flags.OptimisticRelayFileInfo)
{
- // todo: force a remote scan
- throw new NotFoundException($"The file '{localFilename}' could not be located on Agent {host}. A share scan should be performed.");
+ localFileLength = resolvedFileLength;
}
+ else
+ {
+ var (exists, length) = await Relay.GetFileInfoAsync(agentName: host, filename);
- localFileLength = length;
+ if (!exists || length <= 0)
+ {
+ // todo: force a remote scan
+ throw new NotFoundException($"The file '{localFilename}' could not be located on Agent {host}. A share scan should be performed.");
+ }
+
+ localFileLength = length;
+ }
}
}
catch (NotFoundException)