aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Shares/SharedFileCache.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2022-03-20 21:06:15 -0500
committerJP Dillingham <jpdillingham@gmail.com>2022-03-20 21:06:15 -0500
commitef73185e540d66a650164909993e84c6e3396aa5 (patch)
tree1b732f21b64c03cf8adcab9df9f975117474e2f6 /src/slskd/Shares/SharedFileCache.cs
parent1deff8981e2f8dd8edb077501a6fbc106ff17988 (diff)
downloadslskd-ef73185e540d66a650164909993e84c6e3396aa5.tar.gz
move extension method to SoulseekFileFactory
Diffstat (limited to 'src/slskd/Shares/SharedFileCache.cs')
-rw-r--r--src/slskd/Shares/SharedFileCache.cs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/slskd/Shares/SharedFileCache.cs b/src/slskd/Shares/SharedFileCache.cs
index f13eaad4..d68cbc3b 100644
--- a/src/slskd/Shares/SharedFileCache.cs
+++ b/src/slskd/Shares/SharedFileCache.cs
@@ -86,10 +86,13 @@ namespace slskd.Shares
/// Initializes a new instance of the <see cref="SharedFileCache"/> class.
/// </summary>
/// <param name="optionsMonitor"></param>
+ /// <param name="soulseekFileFactory"></param>
public SharedFileCache(
- IOptionsMonitor<Options> optionsMonitor)
+ IOptionsMonitor<Options> optionsMonitor,
+ ISoulseekFileFactory soulseekFileFactory = null)
{
OptionsMonitor = optionsMonitor;
+ SoulseekFileFactory = soulseekFileFactory ?? new SoulseekFileFactory();
}
/// <summary>
@@ -105,6 +108,7 @@ namespace slskd.Shares
private List<Share> Shares { get; set; }
private SqliteConnection SQLite { get; set; }
private SemaphoreSlim SyncRoot { get; } = new SemaphoreSlim(1);
+ private ISoulseekFileFactory SoulseekFileFactory { get; }
/// <summary>
/// Returns the contents of the cache.
@@ -249,8 +253,8 @@ namespace slskd.Shares
try
{
var newFiles = System.IO.Directory.GetFiles(directory, "*", SearchOption.TopDirectoryOnly)
- .Select(f => f.ToSoulseekFile(share))
- .ToDictionary(f => f.Filename, f => f);
+ .Select(filename => SoulseekFileFactory.Create(filename, share.LocalPath, share.RemotePath))
+ .ToDictionary(file => file.Filename, file => file);
// merge the new dictionary with the rest this will overwrite any duplicate keys, but keys are the fully
// qualified name the only time this *should* cause problems is if one of the shares is a subdirectory of another.