aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Users/UserService.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2022-02-06 17:17:23 -0600
committerJP Dillingham <jpdillingham@gmail.com>2022-02-06 17:17:23 -0600
commit47b72c9c60482f05afb93788fcaa983b9e287320 (patch)
tree2a8bb93ec89a72715eb5a5b32ca281474e3bd5a6 /src/slskd/Users/UserService.cs
parent80b2b5f675a857e446c3a3dcc4cb3ad3c8b70a31 (diff)
downloadslskd-47b72c9c60482f05afb93788fcaa983b9e287320.tar.gz
simplify hashing/options debounce
Diffstat (limited to 'src/slskd/Users/UserService.cs')
-rw-r--r--src/slskd/Users/UserService.cs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/slskd/Users/UserService.cs b/src/slskd/Users/UserService.cs
index b6ae4e30..a54005f1 100644
--- a/src/slskd/Users/UserService.cs
+++ b/src/slskd/Users/UserService.cs
@@ -59,11 +59,19 @@ namespace slskd.Users
private ISoulseekClient Client { get; }
private IDbContextFactory<UserDbContext> ContextFactory { get; }
private IOptionsMonitor<Options> OptionsMonitor { get; }
+ private string LastOptionsHash { get; set; }
private ILogger Log { get; set; } = Serilog.Log.ForContext<UserService>();
private ConcurrentDictionary<string, string> Map { get; set; } = new ConcurrentDictionary<string, string>();
private void Configure(Options options)
{
+ var optionsHash = Compute.Sha1Hash(options.Groups.UserDefined.ToJson());
+
+ if (optionsHash == LastOptionsHash)
+ {
+ return;
+ }
+
var map = new ConcurrentDictionary<string, string>();
// sort by priority, ascending
@@ -79,7 +87,7 @@ namespace slskd.Users
}
Map = map;
- Log.Debug("Updated user/group map with {Count} entries", Map.Count);
+ LastOptionsHash = optionsHash;
}
public string GetGroup(string username)