From 7c9863e606d7684d543c730cc2c2c0d5aae4d748 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 12 Aug 2022 09:48:05 -0500 Subject: add GetGroupInfo --- src/slskd/Transfers/Uploads/UploadQueue.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src') diff --git a/src/slskd/Transfers/Uploads/UploadQueue.cs b/src/slskd/Transfers/Uploads/UploadQueue.cs index 9ac6b385..36e5474c 100644 --- a/src/slskd/Transfers/Uploads/UploadQueue.cs +++ b/src/slskd/Transfers/Uploads/UploadQueue.cs @@ -56,6 +56,13 @@ namespace slskd.Transfers /// The filename to enqueue. void Enqueue(string username, string filename); + /// + /// Gets information about the specified . + /// + /// The name of the group. + /// The group information. + UploadGroup GetGroupInfo(string groupName); + /// /// Computes the estimated queue position of the specified for the specified . /// @@ -223,6 +230,21 @@ namespace slskd.Transfers } } + /// + /// Gets information about the specified . + /// + /// The name of the group. + /// The group information. + public UploadGroup GetGroupInfo(string groupName) + { + if (Groups.TryGetValue(groupName, out var group)) + { + return group; + } + + throw new NotFoundException($"A group with the name {groupName} could not be found"); + } + /// /// Computes the estimated queue position of the specified for the specified . /// -- cgit v1.2.3 From 1604fc912aece27e9be4e60ea421d1d80023f7c5 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 12 Aug 2022 09:48:26 -0500 Subject: return actual data in UserInfoResolver --- src/slskd/Application.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index cf37d933..c5c66cf1 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -973,10 +973,19 @@ namespace slskd { try { + var groupName = Users.GetGroup(username); + var group = Transfers.Uploads.Queue.GetGroupInfo(groupName); + + var forecastedPosition = Transfers.Uploads.Queue.ForecastPosition(username); + + // if i get a user's info to determine whether i want to download files from them, + // i want to know how many slots they have, which gives me an idea of how fast their + // queue moves, and the length of the queue *ahead of me*, meaning how long i'd have to + // wait until my first download starts. var info = new UserInfo( description: Options.Soulseek.Description, - uploadSlots: 1, - queueLength: 0, + uploadSlots: group.Slots, + queueLength: forecastedPosition, hasFreeUploadSlot: false); return Task.FromResult(info); -- cgit v1.2.3