From ef73185e540d66a650164909993e84c6e3396aa5 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 20 Mar 2022 21:06:15 -0500 Subject: move extension method to SoulseekFileFactory --- src/slskd/Shares/SharedFileCache.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/slskd/Shares/SharedFileCache.cs') 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 class. /// /// + /// public SharedFileCache( - IOptionsMonitor optionsMonitor) + IOptionsMonitor optionsMonitor, + ISoulseekFileFactory soulseekFileFactory = null) { OptionsMonitor = optionsMonitor; + SoulseekFileFactory = soulseekFileFactory ?? new SoulseekFileFactory(); } /// @@ -105,6 +108,7 @@ namespace slskd.Shares private List Shares { get; set; } private SqliteConnection SQLite { get; set; } private SemaphoreSlim SyncRoot { get; } = new SemaphoreSlim(1); + private ISoulseekFileFactory SoulseekFileFactory { get; } /// /// 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. -- cgit v1.2.3