aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Users/UserService.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2022-02-22 21:26:27 -0600
committerJP Dillingham <jpdillingham@gmail.com>2022-02-22 21:26:27 -0600
commitec21875fb748bc91b4df85ea62c4813815e25b4a (patch)
treedc6d00e2e981fc6db77ed0d7a160c462c8e32fb0 /src/slskd/Users/UserService.cs
parent979acc196f01bf53bf0141cf80f684172433d472 (diff)
downloadslskd-ec21875fb748bc91b4df85ea62c4813815e25b4a.tar.gz
purge transient users on disconnect
Diffstat (limited to 'src/slskd/Users/UserService.cs')
-rw-r--r--src/slskd/Users/UserService.cs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/slskd/Users/UserService.cs b/src/slskd/Users/UserService.cs
index 39647e0a..4e252f40 100644
--- a/src/slskd/Users/UserService.cs
+++ b/src/slskd/Users/UserService.cs
@@ -253,7 +253,21 @@ namespace slskd.Users
};
Client.LoggedIn += (_, _) => WatchAllUsers();
- Client.Disconnected += (_, _) => WatchedUsernamesDictionary.Clear();
+ Client.Disconnected += (_, _) =>
+ {
+ // when the client is disconnected, the watched user list resets server-side,
+ // so clear the watched dictionary to reflect this
+ WatchedUsernamesDictionary.Clear();
+
+ // over the course of operation the application will watch users which are not explicitly
+ // configured as they enqueue uploads. these are considered transiently-tracked users,
+ // and we want to discard them upon disconnect to avoid re-watching them when the client
+ // is reconnected. to do this, purge the user dictionary of any entry lacking an explicit group.
+ foreach (var user in UserDictionary.Values.Where(user => user.Group == null))
+ {
+ UserDictionary.TryRemove(user.Username, out _);
+ }
+ };
}
private void Configure(Options options)