diff options
| -rw-r--r-- | src/slskd/Application.cs | 13 | ||||
| -rw-r--r-- | src/slskd/Transfers/Uploads/UploadQueue.cs | 22 |
2 files changed, 33 insertions, 2 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 20f790fb..d0c9adc1 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); 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 @@ -57,6 +57,13 @@ namespace slskd.Transfers void Enqueue(string username, string filename); /// <summary> + /// Gets information about the specified <paramref name="groupName"/>. + /// </summary> + /// <param name="groupName">The name of the group.</param> + /// <returns>The group information.</returns> + UploadGroup GetGroupInfo(string groupName); + + /// <summary> /// Computes the estimated queue position of the specified <paramref name="filename"/> for the specified <paramref name="username"/>. /// </summary> /// <param name="username">The username associated with the file.</param> @@ -224,6 +231,21 @@ namespace slskd.Transfers } /// <summary> + /// Gets information about the specified <paramref name="groupName"/>. + /// </summary> + /// <param name="groupName">The name of the group.</param> + /// <returns>The group information.</returns> + 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"); + } + + /// <summary> /// Computes the estimated queue position of the specified <paramref name="filename"/> for the specified <paramref name="username"/>. /// </summary> /// <param name="username">The username associated with the file.</param> |
