aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Network/API/Controllers/NetworkController.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2022-10-22 18:28:26 -0500
committerJP Dillingham <jpdillingham@gmail.com>2022-10-22 18:28:26 -0500
commit9921a9c17e6c09e04bb3370332b4ade1956b682c (patch)
tree4bcfed5a14c8c1a26ae0f03be96c130a5f494579 /src/slskd/Network/API/Controllers/NetworkController.cs
parent6ecaee7f09f8861cd281d81e97c160dadb041021 (diff)
downloadslskd-9921a9c17e6c09e04bb3370332b4ade1956b682c.tar.gz
simplify stream handling
Diffstat (limited to 'src/slskd/Network/API/Controllers/NetworkController.cs')
-rw-r--r--src/slskd/Network/API/Controllers/NetworkController.cs32
1 files changed, 9 insertions, 23 deletions
diff --git a/src/slskd/Network/API/Controllers/NetworkController.cs b/src/slskd/Network/API/Controllers/NetworkController.cs
index cecaa39c..3ae2a6b5 100644
--- a/src/slskd/Network/API/Controllers/NetworkController.cs
+++ b/src/slskd/Network/API/Controllers/NetworkController.cs
@@ -81,31 +81,17 @@ namespace slskd.Network
return Unauthorized();
}
- // get the record for the waiting file
- if (Network.PendingFileUploads.TryGetValue(guid, out var record))
- {
- // get the stream from the multipart upload
- var stream = Request.Form.Files.First().OpenReadStream();
-
- // set the result for the stream
- // this should pass control to the transfer service along with
- // the stream
- record.Stream.SetResult(stream);
+ // get the stream from the multipart upload
+ var stream = Request.Form.Files.First().OpenReadStream();
- Console.WriteLine("Stream handed off. Waiting for completion...");
+ // pass the stream back to the network service, which will in turn pass it to the
+ // upload service, and use it to feed data into the remote upload. await this call,
+ // it will complete when the upload is complete.
+ await Network.HandleGetFileStreamResponse(agentName, filename: file.FileName, id: guid, stream);
- // wait for the transfer service to set the completion result
- await record.Completion.Task;
-
- stream.Dispose();
- Console.WriteLine("Upload complete");
- return Ok();
- }
- else
- {
- Log.Warning("Agent");
- return NotFound();
- }
+ stream.Dispose();
+ Console.WriteLine("Upload complete");
+ return Ok();
}
[HttpPost("shares/{agentName}/{token}")]