aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Network/API
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2022-10-15 19:09:41 -0500
committerJP Dillingham <jpdillingham@gmail.com>2022-10-15 19:09:41 -0500
commit8663b3fac9597f7b0c6ffd8081b99c761a18b326 (patch)
tree6780fbd2e1b950f60f2bf7f57dcd963d853df50b /src/slskd/Network/API
parent7e34146d679b3b6c1692a41f1ea9ab4547889a43 (diff)
downloadslskd-8663b3fac9597f7b0c6ffd8081b99c761a18b326.tar.gz
add file info handling
Diffstat (limited to 'src/slskd/Network/API')
-rw-r--r--src/slskd/Network/API/Hubs/NetworkHub.cs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/slskd/Network/API/Hubs/NetworkHub.cs b/src/slskd/Network/API/Hubs/NetworkHub.cs
index 6d43e6da..f79fecf2 100644
--- a/src/slskd/Network/API/Hubs/NetworkHub.cs
+++ b/src/slskd/Network/API/Hubs/NetworkHub.cs
@@ -26,6 +26,7 @@ namespace slskd.Network
public static class NetworkHubMethods
{
public static readonly string RequestFile = "REQUEST_FILE";
+ public static readonly string RequestFileInfo = "REQUEST_FILE_INFO";
public static readonly string AuthenticationChallenge = "AUTHENTICATION_CHALLENGE";
public static readonly string AuthenticationChallengeAccepted = "AUTHENTICATION_CHALLENGE_ACCEPTED";
public static readonly string AuthenticationChallengeRejected = "AUTHENTICATION_CHALLENGE_REJECTED";
@@ -41,6 +42,11 @@ namespace slskd.Network
// todo: how to send this to the specified agent?
return hub.Clients.All.SendAsync(NetworkHubMethods.RequestFile, filename, id);
}
+
+ public static Task RequestFileInfoAsync(this IHubContext<NetworkHub> hub, string agent, string filename, Guid id)
+ {
+ return hub.Clients.All.SendAsync(NetworkHubMethods.RequestFileInfo, filename, id);
+ }
}
/// <summary>
@@ -104,7 +110,15 @@ namespace slskd.Network
{
if (Network.PendingFileUploads.TryGetValue(id, out var record))
{
- record.Stream.SetException(new NotFoundException("The file could not be uploaded from the remote agent"));
+ record.Stream.TrySetException(new NotFoundException("The file could not be uploaded from the remote agent"));
+ }
+ }
+
+ public void ReturnFileInfo(Guid id, bool exists, long length)
+ {
+ if (Network.PendingFileInquiries.TryGetValue(id, out var record))
+ {
+ record.TrySetResult((exists, length));
}
}
}