diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-11-04 18:37:28 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-11-04 18:37:28 -0500 |
| commit | a2a4a0c7fbe9630ff0a94ea75a6fbef1dcfa143f (patch) | |
| tree | 49bc05f2add4d724acb580b9c088bcf7a494eadc /src | |
| parent | 936459e44baed4a588327677b920d33ab8246b71 (diff) | |
| download | slskd-a2a4a0c7fbe9630ff0a94ea75a6fbef1dcfa143f.tar.gz | |
rebuild browse cache when hosts change
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Application.cs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 68f0276b..8aaa0470 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -996,6 +996,7 @@ namespace slskd private void ShareState_OnChange((ShareState Previous, ShareState Current) state) { var (previous, current) = state; + bool rebuildBrowseCache = false; if (!previous.Scanning && current.Scanning) { @@ -1019,7 +1020,7 @@ namespace slskd { State.SetValue(state => state with { Shares = state.Shares with { ScanPending = false } }); Log.Information("Shares scanned successfully. Found {Directories} directories and {Files} files in {Duration}ms", current.Directories, current.Files, (DateTime.UtcNow - SharesRefreshStarted).TotalMilliseconds); - _ = CacheBrowseResponse(); + rebuildBrowseCache = true; SharesRefreshStarted = default; @@ -1038,7 +1039,7 @@ namespace slskd // the share transitioned into ready without completing a scan; it was loaded from disk State.SetValue(state => state with { Shares = current with { ScanPending = false } }); Log.Information("Share cache loaded from disk successfully. Sharing {Directories} directories and {Files} files", current.Directories, current.Files); - _ = CacheBrowseResponse(); + rebuildBrowseCache = true; } else { @@ -1052,6 +1053,11 @@ namespace slskd Log.Information("Scanned {Percent}% of shared directories. Found {Files} files so far.", currentProgress, current.Files); } } + + if (rebuildBrowseCache || previous.Hosts.ToJson() != current.Hosts.ToJson()) + { + _ = CacheBrowseResponse(); + } } private async Task<BrowseResponse> CacheBrowseResponse() |
