aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-09-11 18:13:24 -0500
committerGitHub <noreply@github.com>2022-09-11 18:13:24 -0500
commite7b57da3dad5dacb6dbbc59c1464950eb170b0b4 (patch)
tree951f5f3531e3d69c99c9fd202d4467b4ff1d46ad /src/slskd/Application.cs
parent3d657ed87cfdab4089c72d9e6532d9b2cc83aa4e (diff)
parenta596dfe252ef53e41b91ec6773aec93307c41f1e (diff)
downloadslskd-e7b57da3dad5dacb6dbbc59c1464950eb170b0b4.tar.gz
Merge pull request #641 from slskd/in-memory
Refactor share options, add option to allow users to select between on-disk and in-memory share caching
Diffstat (limited to 'src/slskd/Application.cs')
-rw-r--r--src/slskd/Application.cs26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index f3feec23..cab2b649 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("Share cache 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");
}