aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Relay/API/Controllers/RelayController.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-11-15 17:40:00 -0600
committerJP Dillingham <jp@dillingham.me>2026-11-15 17:40:00 -0600
commite0a777403e15eaeefc7881d9451aef2f26bf3f4c (patch)
treeca2fabd619994e96c848c8ea938bcfa3443ebb9f /src/slskd/Relay/API/Controllers/RelayController.cs
parent2a3e057e5b3dbc7bf55c430f10ef91e036984b2b (diff)
downloadslskd-e0a777403e15eaeefc7881d9451aef2f26bf3f4c.tar.gz
ensure uploaded share stream is flushed before loading
Diffstat (limited to 'src/slskd/Relay/API/Controllers/RelayController.cs')
-rw-r--r--src/slskd/Relay/API/Controllers/RelayController.cs12
1 files changed, 7 insertions, 5 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);