diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-10-14 08:57:18 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-10-14 08:57:18 -0500 |
| commit | 4d69426a19ffff519368ec2b75e8634fdd23d861 (patch) | |
| tree | d2de40606e3c3fa901effe2d543adb20974b93c4 /src/slskd/Shares/ShareScanner.cs | |
| parent | b56a6650e95b3964d22d0af8c4c44b74d2800c29 (diff) | |
| parent | 593308d4e786cd569e3a683f5b02b8f13aa39b23 (diff) | |
| download | slskd-4d69426a19ffff519368ec2b75e8634fdd23d861.tar.gz | |
Merge remote-tracking branch 'origin/master' into agent
Diffstat (limited to 'src/slskd/Shares/ShareScanner.cs')
| -rw-r--r-- | src/slskd/Shares/ShareScanner.cs | 15 |
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(); |
