aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Relay/RelayService.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-11-23 16:30:21 -0600
committerGitHub <noreply@github.com>2022-11-23 16:30:21 -0600
commit31694fc9b2cdf69413853ce2c362e4b5d3c47401 (patch)
tree6be2eb4e82aee664f5d03e7f0645f6ccf55c76e4 /src/slskd/Relay/RelayService.cs
parente6c12a2ffb9260db7236b5d79f474b1c69ef6bc9 (diff)
parentec9ea5821f71d6c3643babc8483cc06ca6e52f75 (diff)
downloadslskd-31694fc9b2cdf69413853ce2c362e4b5d3c47401.tar.gz
Merge pull request #780 from slskd/relay-offset
Add support for resume-able uploads from Relay Agents
Diffstat (limited to 'src/slskd/Relay/RelayService.cs')
-rw-r--r--src/slskd/Relay/RelayService.cs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/slskd/Relay/RelayService.cs b/src/slskd/Relay/RelayService.cs
index 3b872816..c4fb13a9 100644
--- a/src/slskd/Relay/RelayService.cs
+++ b/src/slskd/Relay/RelayService.cs
@@ -143,11 +143,12 @@ namespace slskd.Relay
/// </remarks>
/// <param name="agentName">The agent from which to retrieve the file.</param>
/// <param name="filename">The file to retrieve.</param>
+ /// <param name="startOffset">The starting offset for the transfer.</param>
/// <param name="id">A unique ID for the stream.</param>
/// <param name="timeout">An optional timeout value.</param>
/// <param name="cancellationToken">An optional token to monitor for cancellation requests.</param>
/// <returns>The operation context, including a stream containing the requested file.</returns>
- Task<Stream> GetFileStreamAsync(string agentName, string filename, Guid id, int timeout = 3000, CancellationToken cancellationToken = default);
+ Task<Stream> GetFileStreamAsync(string agentName, string filename, long startOffset, Guid id, int timeout = 3000, CancellationToken cancellationToken = default);
/// <summary>
/// Handles the client response for a <see cref="GetFileInfoAsync"/> request.
@@ -444,11 +445,12 @@ namespace slskd.Relay
/// </remarks>
/// <param name="agentName">The agent from which to retrieve the file.</param>
/// <param name="filename">The file to retrieve.</param>
+ /// <param name="startOffset">The starting offset for the transfer.</param>
/// <param name="id">A unique ID for the stream.</param>
/// <param name="timeout">An optional timeout value.</param>
/// <param name="cancellationToken">An optional token to monitor for cancellation requests.</param>
/// <returns>The operation context, including a stream containing the requested file.</returns>
- public async Task<Stream> GetFileStreamAsync(string agentName, string filename, Guid id, int timeout = 3000, CancellationToken cancellationToken = default)
+ public async Task<Stream> GetFileStreamAsync(string agentName, string filename, long startOffset, Guid id, int timeout = 3000, CancellationToken cancellationToken = default)
{
if (!RegisteredAgentDictionary.TryGetValue(agentName, out var record))
{
@@ -468,7 +470,7 @@ namespace slskd.Relay
Log.Information("Created wait {Key}", key);
- await RelayHub.Clients.Client(record.ConnectionId).RequestFileUpload(filename, id);
+ await RelayHub.Clients.Client(record.ConnectionId).RequestFileUpload(filename, startOffset, id);
Log.Information("Requested file {Filename} from Agent {Agent} with ID {Id}. Waiting for incoming connection.", filename, agentName, id);
var task = await Task.WhenAny(wait, Task.Delay(timeout, cancellationToken));