diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-11-16 08:46:50 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-16 08:46:50 -0600 |
| commit | fe41700f5466c434ad984ca0e273e08c66d3597a (patch) | |
| tree | 9880a9f83cd6c809f2b7cdd954661055780643fd /src/slskd/Relay/API | |
| parent | 0bfe5062ea6cc3d3dadef7c88497c2a15a573ece (diff) | |
| parent | 1d092bf0b18ba44c0547838715a721900cb4a569 (diff) | |
| download | slskd-fe41700f5466c434ad984ca0e273e08c66d3597a.tar.gz | |
Merge pull request #1928 from slskd/relay
Minor Relay improvements
Diffstat (limited to 'src/slskd/Relay/API')
| -rw-r--r-- | src/slskd/Relay/API/Controllers/RelayController.cs | 12 | ||||
| -rw-r--r-- | src/slskd/Relay/API/Hubs/RelayHub.cs | 8 |
2 files changed, 11 insertions, 9 deletions
diff --git a/src/slskd/Relay/API/Controllers/RelayController.cs b/src/slskd/Relay/API/Controllers/RelayController.cs index ddb8d0b0..0be59b13 100644 --- a/src/slskd/Relay/API/Controllers/RelayController.cs +++ b/src/slskd/Relay/API/Controllers/RelayController.cs @@ -354,14 +354,16 @@ namespace slskd.Relay var sw = new Stopwatch(); sw.Start(); - using var outputStream = new FileStream(temp, FileMode.CreateNew, FileAccess.Write); - using var inputStream = database.OpenReadStream(); - - await inputStream.CopyToAsync(outputStream); + // the streams must be closed (and the output flushed) before the file is handed off to be opened as a database + using (var outputStream = new FileStream(temp, FileMode.CreateNew, FileAccess.Write)) + using (var inputStream = database.OpenReadStream()) + { + await inputStream.CopyToAsync(outputStream); + } sw.Stop(); - Log.Information("Download of shares from {Agent} ({Token}) complete ({Size} in {Duration}ms)", agentName, guid, ((double)inputStream.Length).SizeSuffix(), sw.ElapsedMilliseconds); + Log.Information("Download of shares from {Agent} ({Token}) complete ({Size} in {Duration}ms)", agentName, guid, ((double)database.Length).SizeSuffix(), sw.ElapsedMilliseconds); await Relay.HandleShareUploadAsync(agentName, id: guid, shares, temp); diff --git a/src/slskd/Relay/API/Hubs/RelayHub.cs b/src/slskd/Relay/API/Hubs/RelayHub.cs index e839cd1a..4e044bdb 100644 --- a/src/slskd/Relay/API/Hubs/RelayHub.cs +++ b/src/slskd/Relay/API/Hubs/RelayHub.cs @@ -223,9 +223,9 @@ namespace slskd.Relay /// Executed by the agent to notify the controller that the agent was unable to upload the file requested by a call to <see cref="IRelayHub.RequestFileUpload"/>. /// </summary> /// <param name="id">The unique identifier of the request.</param> - /// <param name="exception">The Exception that caused the failure.</param> + /// <param name="message">A message describing the failure.</param> /// <exception cref="UnauthorizedAccessException">Thrown when the agent is not fully authenticated.</exception> - public void NotifyFileUploadFailed(Guid id, Exception exception) + public void NotifyFileUploadFailed(Guid id, string message) { if (!Relay.TryGetAgentRegistration(Context.ConnectionId, out var record)) { @@ -233,9 +233,9 @@ namespace slskd.Relay throw new UnauthorizedAccessException(); } - Log.Warning("Agent {Agent} (connection {ConnectionId}) from {IP} reported upload failure for {Id}: {Message}", record.Agent, Context.ConnectionId, GetRemoteIPAddress(), id, exception.Message); + Log.Warning("Agent {Agent} (connection {ConnectionId}) from {IP} reported upload failure for {Id}: {Message}", record.Agent.Name, Context.ConnectionId, GetRemoteIPAddress(), id, message); - Relay.NotifyFileStreamException(record.Agent.Name, id, exception); + Relay.NotifyFileStreamException(record.Agent.Name, id, new RelayException(message)); } /// <summary> |
