aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2022-02-19 16:52:02 -0600
committerJP Dillingham <jpdillingham@gmail.com>2022-02-19 16:52:02 -0600
commit136204584f16c5abc5e8dede8b68e1c162d2febc (patch)
tree291be3c41b2975878f967685a3b7866c37a969a0 /src/slskd/Application.cs
parent50b22754dc63a993d1b7e7cbfc6809d39a8935c4 (diff)
downloadslskd-136204584f16c5abc5e8dede8b68e1c162d2febc.tar.gz
check user privileges prior to upload
Diffstat (limited to 'src/slskd/Application.cs')
-rw-r--r--src/slskd/Application.cs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index 83f18a52..840ed1ba 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -82,6 +82,7 @@ namespace slskd
IConversationTracker conversationTracker,
IRoomTracker roomTracker,
IRoomService roomService,
+ IUserService userService,
ISharedFileCache sharedFileCache,
IPushbulletService pushbulletService,
IHubContext<ApplicationHub> applicationHub,
@@ -107,6 +108,7 @@ namespace slskd
Pushbullet = pushbulletService;
RoomService = roomService;
+ Users = userService;
ApplicationHub = applicationHub;
LogHub = logHub;
@@ -157,6 +159,7 @@ namespace slskd
private ITransferService Transfers { get; init; }
private IHubContext<ApplicationHub> ApplicationHub { get; set; }
private IHubContext<LogsHub> LogHub { get; set; }
+ private IUserService Users { get; set; }
public void CollectGarbage()
{
@@ -587,6 +590,14 @@ namespace slskd
// uploads would be handled separately.
Task.Run(async () =>
{
+ // prime the privileges cache for this user
+ // this must be done prior to each upload, or we risk not correctly categorizing
+ // privileged users as such.
+ if (await Users.IsPrivilegedAsync(username))
+ {
+ Log.Debug("User {Username} is privileged; upload will be prioritized", username);
+ }
+
using var stream = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read);
await Client.UploadAsync(username, filename, fileInfo.FullName, options: topts, cancellationToken: cts.Token);
}).ContinueWith(t =>