aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-10-05 10:10:55 -0500
committerGitHub <noreply@github.com>2026-10-05 10:10:55 -0500
commit7c302a753b1814345fcb26eb78dec97db6b698df (patch)
tree54bc206b20410009c32a2f8c9aa4579b50ecec78 /src/slskd/Application.cs
parent2d432e52cbe7e8483783010fe3f8f1415245c1a5 (diff)
parentb0ca0504c8c13bbe73401ac00d16e13d5a4fda70 (diff)
downloadslskd-7c302a753b1814345fcb26eb78dec97db6b698df.tar.gz
Merge pull request #1869 from slskd/upload-queue-fixes
Remove GetGroupInfo, return slot info in ForecastPosition instead
Diffstat (limited to 'src/slskd/Application.cs')
-rw-r--r--src/slskd/Application.cs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index 8de4fe53..c34cd316 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -1749,7 +1749,7 @@ namespace slskd
// note: the following uses cached user data to determine group, so if the user's data
// isn't cached they may get a forecast based on the wrong group. this is a hot path though,
// and we don't want to incur the massive penalties that would caching data for each request.
- var forecastedPosition = Transfers.Uploads.Queue.ForecastPosition(username);
+ var (groupName, totalSlots, freeSlots, forecastedPosition) = Transfers.Uploads.Queue.ForecastPosition(username);
Log.Debug("Sending search response with {Count} files to {Username} for query '{Query}'", results.Count(), username, query.SearchText);
@@ -1757,7 +1757,7 @@ namespace slskd
Client.Username,
token,
uploadSpeed: State.CurrentValue.User.Statistics.AverageSpeed,
- hasFreeUploadSlot: forecastedPosition == 0,
+ hasFreeUploadSlot: freeSlots > 0,
queueLength: forecastedPosition,
fileList: results);
}
@@ -1957,12 +1957,11 @@ namespace slskd
// we are deliberately skipping it here; if the username is watched
// leech detection works and they get accurate info, if not, they won't
var groupName = await Users.GetOrFetchGroupAsync(username);
- var group = Transfers.Uploads.Queue.GetGroupInfo(groupName);
// forecast the position at which this user would enter the queue if they were to request
// a file at this moment. this will be zero if a slot is available and the transfer would
// begin immediately
- var forecastedPosition = Transfers.Uploads.Queue.ForecastPosition(username);
+ var (group, totalSlots, freeSlots, 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
@@ -1971,9 +1970,9 @@ namespace slskd
// revisited 3 years later: why was it important to leave this comment??
var info = new UserInfo(
description: Options.Soulseek.Description,
- uploadSlots: group.Slots,
+ uploadSlots: totalSlots,
queueLength: forecastedPosition,
- hasFreeUploadSlot: forecastedPosition == 0,
+ hasFreeUploadSlot: freeSlots > 0,
picture: pictureBytes);
return info;