diff options
| author | JP Dillingham <jp@dillingham.me> | 2023-12-26 21:18:49 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2023-12-26 21:18:49 -0600 |
| commit | de6d7017ef5efbfe594be516278139265ca6668e (patch) | |
| tree | e4b2574de1871ab504371f86decc7588cc125e05 | |
| parent | 01aae2fabc178d03b4ee2db0d0059b8f14e2dc7a (diff) | |
| download | slskd-de6d7017ef5efbfe594be516278139265ca6668e.tar.gz | |
wip
| -rw-r--r-- | src/slskd/Application.cs | 17 | ||||
| -rw-r--r-- | src/slskd/Shares/ShareService.cs | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index be7dde15..4bbbff8b 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -766,18 +766,22 @@ namespace slskd private async Task MaybeRescanShares() { + Log.Warning("Running MaybeRescanShares"); + // ignore this if we're already scanning. there are multiple safeguards using // SemaphoreSlim later in the call chain if we manage to slip by somehow, though if (Shares.StateMonitor.CurrentValue.Scanning) { + Log.Warning("Already scanning"); return; } var ttl = Options.Shares.Cache.Retention; // no configured TTL; never re-scan automatically - if (!ttl.HasValue == default) + if (!ttl.HasValue) { + Log.Warning("No ttl configured"); return; } @@ -786,12 +790,13 @@ namespace slskd .AddMinutes(-ttl.Value) .ToUnixTimeMilliseconds(); - // get all scan records that started on or after our cutoff. we can't rely on - // EndedAt here because one or more prior scans may have failed, leaving the - // field null. we still want to attempt to re-scan if that is the case. we will rely - // on the locking implemented in the service to prevent overlapping scans - var matchingScans = await Shares.ListScansAsync(s => s.StartedAt >= cutoffTimestamp); + // get a list of all scans 1) started after our cutoff timestamp, 2) that succeeded (have a valid EndedAt) and + // 3) have not been marked suspect + var matchingScans = await Shares.ListScansAsync(s => s.StartedAt >= cutoffTimestamp && s.EndedAt != null && !s.Suspect); + + Log.Warning("Scans: {@s}", matchingScans); + // if there's no scan that meets all 3 criteria, try to re-scan if (!matchingScans.Any()) { // fire and forget. if something slips through the underlying logic will log. diff --git a/src/slskd/Shares/ShareService.cs b/src/slskd/Shares/ShareService.cs index 7ca366b7..c1622ee4 100644 --- a/src/slskd/Shares/ShareService.cs +++ b/src/slskd/Shares/ShareService.cs @@ -458,7 +458,7 @@ namespace slskd.Shares var options = OptionsMonitor.CurrentValue.Shares; var latestScan = Local.Repository.FindLatestScan(); - Log.Debug("Latest scan: {Scan}, current options {Options}", latestScan, options); + Log.Debug("Latest scan: {Scan}, current options {@Options}", latestScan, options); if (latestScan == default) { |
