diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-10-09 18:02:11 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-10-09 18:02:11 -0500 |
| commit | 3345653b6b5293215b5eda2516e9c96bced83ab2 (patch) | |
| tree | 1f10e872cabb18a0f9b050210831782d13a9b188 /src/slskd/Shares/ShareScanner.cs | |
| parent | 1c81c5244a892da6b38600c2969debb323ff2c24 (diff) | |
| download | slskd-3345653b6b5293215b5eda2516e9c96bced83ab2.tar.gz | |
implement more explicit schema checks, add scans table
Diffstat (limited to 'src/slskd/Shares/ShareScanner.cs')
| -rw-r--r-- | src/slskd/Shares/ShareScanner.cs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/slskd/Shares/ShareScanner.cs b/src/slskd/Shares/ShareScanner.cs index 369e4981..74f0d131 100644 --- a/src/slskd/Shares/ShareScanner.cs +++ b/src/slskd/Shares/ShareScanner.cs @@ -44,9 +44,9 @@ namespace slskd.Shares /// Scans the configured shares and fills the cache. /// </summary> /// <param name="shares">The list of shares from which to fill the cache.</param> - /// <param name="filters">The list of regular expressions used to exclude files or paths from scanning.</param> + /// <param name="options">The current options snapshot.</param> /// <returns>The operation context.</returns> - Task ScanAsync(IEnumerable<Share> shares, IEnumerable<Regex> filters); + Task ScanAsync(IEnumerable<Share> shares, Options.SharesOptions options); /// <summary> /// Cancels the currently running fill operation, if one is running. @@ -90,9 +90,9 @@ namespace slskd.Shares /// Scans the configured shares and fills the cache. /// </summary> /// <param name="shares">The list of shares from which to fill the cache.</param> - /// <param name="filters">The list of regular expressions used to exclude files or paths from scanning.</param> + /// <param name="options">The current options snapshot.</param> /// <returns>The operation context.</returns> - public async Task ScanAsync(IEnumerable<Share> shares, IEnumerable<Regex> filters) + public async Task ScanAsync(IEnumerable<Share> shares, Options.SharesOptions options) { // obtain the semaphore, or fail if it can't be obtained immediately, indicating that a scan is running. if (!await SyncRoot.WaitAsync(millisecondsTimeout: 0)) @@ -130,10 +130,16 @@ namespace slskd.Shares Log.Information("Shared file cache re-created and ready for scan."); } + var filters = options.Filters + .Select(filter => new Regex(filter, RegexOptions.Compiled)) + .ToList(); + Log.Information("Starting shared file scan"); var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + Repository.InsertScan(timestamp, options); + var sw = new Stopwatch(); var swSnapshot = 0L; sw.Start(); @@ -316,6 +322,8 @@ namespace slskd.Shares State.SetValue(state => state with { Cancelled = true }); } + 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"); |
