aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Shares/ShareScanner.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/slskd/Shares/ShareScanner.cs')
-rw-r--r--src/slskd/Shares/ShareScanner.cs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/slskd/Shares/ShareScanner.cs b/src/slskd/Shares/ShareScanner.cs
index 74f0d131..f5e7e52d 100644
--- a/src/slskd/Shares/ShareScanner.cs
+++ b/src/slskd/Shares/ShareScanner.cs
@@ -65,11 +65,14 @@ namespace slskd.Shares
/// </summary>
/// <param name="workerCount"></param>
/// <param name="soulseekFileFactory"></param>
- public ShareScanner(int workerCount, ISoulseekFileFactory soulseekFileFactory = null)
+ public ShareScanner(
+ int workerCount,
+ IReadWriteShareRepository shareRepository,
+ ISoulseekFileFactory soulseekFileFactory = null)
{
WorkerCount = workerCount;
SoulseekFileFactory = soulseekFileFactory ?? new SoulseekFileFactory();
- Repository = new ShareRepository(Program.ConnectionStrings.Shares);
+ Repository = shareRepository;
}
/// <summary>
@@ -84,7 +87,7 @@ namespace slskd.Shares
private IManagedState<SharedFileCacheState> State { get; } = new ManagedState<SharedFileCacheState>();
private SemaphoreSlim SyncRoot { get; } = new SemaphoreSlim(1);
private CancellationTokenSource CancellationTokenSource { get; set; }
- private IShareRepository Repository { get; }
+ private IReadWriteShareRepository Repository { get; }
/// <summary>
/// Scans the configured shares and fills the cache.
@@ -123,7 +126,7 @@ namespace slskd.Shares
// it's possible that the database was tampered with between the time it was checked at startup and now
// validate the tables, and if there's an issue, drop and recreate everything.
- if (!ShareRepository.TryValidateDatabase(Program.ConnectionStrings.Shares))
+ if (!Repository.TryValidate())
{
Log.Warning("Shared file cache missing or invalid. Re-creating prior to scan.");
Repository.Create(discardExisting: true);
@@ -324,10 +327,6 @@ namespace slskd.Shares
Repository.UpdateScan(timestamp, DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());
- Log.Debug("Backing up shared file cache database...");
- Repository.BackupTo(Program.ConnectionStrings.SharesBackup);
- Log.Debug("Shared file cache database backup complete");
-
var directoryCount = Repository.CountDirectories();
var fileCount = Repository.CountFiles();