From e624d3bdc8a4eff1f3b97294ced81647b80983e6 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 10 Sep 2022 17:40:30 -0500 Subject: hard code filenames, delete browse cache on scan start --- src/slskd/Application.cs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/slskd/Application.cs') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index f3feec23..288ba07b 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -428,7 +428,7 @@ namespace slskd BrowseResponse response = default; - var cacheFilename = Path.Combine(Program.DataDirectory, Filenames.BrowseCache); + var cacheFilename = Path.Combine(Program.DataDirectory, "browse.cache"); var cacheFileInfo = new FileInfo(cacheFilename); if (!cacheFileInfo.Exists) @@ -780,15 +780,15 @@ namespace slskd pendingReconnect |= requiresReconnect; } - if (PreviousOptions.Directories.Shared.Except(newOptions.Directories.Shared).Any() - || newOptions.Directories.Shared.Except(PreviousOptions.Directories.Shared).Any()) + if (PreviousOptions.Shares.Directories.Except(newOptions.Shares.Directories).Any() + || newOptions.Shares.Directories.Except(PreviousOptions.Shares.Directories).Any()) { State.SetValue(state => state with { Shares = state.Shares with { ScanPending = true } }); Log.Information("Shared directory configuration changed. Shares must be re-scanned for changes to take effect."); } - if (PreviousOptions.Filters.Share.Except(newOptions.Filters.Share).Any() - || newOptions.Filters.Share.Except(PreviousOptions.Filters.Share).Any()) + if (PreviousOptions.Shares.Filters.Except(newOptions.Shares.Filters).Any() + || newOptions.Shares.Filters.Except(PreviousOptions.Shares.Filters).Any()) { State.SetValue(state => state with { Shares = state.Shares with { ScanPending = true } }); Log.Information("File filter configuration changed. Shares must be re-scanned for changes to take effect."); @@ -989,7 +989,17 @@ namespace slskd SharesRefreshStarted = DateTime.UtcNow; State.SetValue(s => s with { Shares = current }); - Log.Information("Scanning shares"); + Log.Information("Share scan started"); + + try + { + System.IO.File.Delete(Path.Combine(Program.DataDirectory, "browse.cache")); + Log.Information("Cleared browse response cache"); + } + catch + { + // noop + } } else if (previous.Scanning && !current.Scanning) { @@ -1022,7 +1032,7 @@ namespace slskd { // the share transitioned into ready without completing a scan; it was loaded from disk State.SetValue(state => state with { Shares = state.Shares with { ScanPending = false } }); - Log.Information("Shares loaded from disk successfully. Sharing {Directories} directories and {Files}", current.Directories, current.Files); + Log.Information("Shares loaded from disk successfully. Sharing {Directories} directories and {Files} files", current.Directories, current.Files); _ = CacheBrowseResponse(); } else @@ -1045,7 +1055,7 @@ namespace slskd var response = new BrowseResponse(directories); Log.Information("Warming browse response cache..."); - System.IO.File.WriteAllBytes(Path.Combine(Program.DataDirectory, Filenames.BrowseCache), response.ToByteArray()); + System.IO.File.WriteAllBytes(Path.Combine(Program.DataDirectory, "browse.cache"), response.ToByteArray()); Log.Information("Browse response cached successfully"); } -- cgit v1.2.3 From a596dfe252ef53e41b91ec6773aec93307c41f1e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 11 Sep 2022 18:09:58 -0500 Subject: tweak logging for consistency --- src/slskd/Application.cs | 2 +- src/slskd/Program.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/slskd/Application.cs') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 288ba07b..cab2b649 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -1032,7 +1032,7 @@ namespace slskd { // the share transitioned into ready without completing a scan; it was loaded from disk State.SetValue(state => state with { Shares = state.Shares with { ScanPending = false } }); - Log.Information("Shares loaded from disk successfully. Sharing {Directories} directories and {Files} files", current.Directories, current.Files); + Log.Information("Share cache loaded from disk successfully. Sharing {Directories} directories and {Files} files", current.Directories, current.Files); _ = CacheBrowseResponse(); } else diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index fe2bb626..e828f242 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -348,12 +348,12 @@ namespace slskd if (OptionsAtStartup.Shares.Cache.StorageMode.ToEnum() == StorageMode.Disk) { - Log.Information("Using on-disk shared file database"); + Log.Information("Using on-disk shared file cache"); shareDbDataSource = Path.Combine(DataDirectory, "shares.db"); } else { - Log.Information("Using in-memory shared file database"); + Log.Information("Using in-memory shared file cache"); shareDbDataSource = "file:shares?mode=memory"; } -- cgit v1.2.3