Extend backward search window to 24 hours for Spotify missing tracks

- Search forward 12 hours from sync time
- Search backward 24 hours from sync time (was 12 hours)
- Ensures yesterday's file is always found when running at 11 AM after 4 PM sync
- Sync runs daily at 4:15 PM, so 24h backward always catches previous day's file
This commit is contained in:
2026-02-01 11:33:42 -05:00
parent c54a32ccfc
commit eb46692b25

View File

@@ -337,12 +337,12 @@ public class SpotifyMissingTracksFetcher : BackgroundService
// If we haven't reached today's sync time yet, start from yesterday's sync time // If we haven't reached today's sync time yet, start from yesterday's sync time
var syncTime = now >= todaySync ? todaySync : todaySync.AddDays(-1); var syncTime = now >= todaySync ? todaySync : todaySync.AddDays(-1);
_logger.LogInformation(" Searching ±12 hours around {SyncTime}", syncTime); _logger.LogInformation(" Searching +12h forward, -24h backward from {SyncTime}", syncTime);
var found = false; var found = false;
// Search forward 12 hours from sync time // Search forward 12 hours from sync time
_logger.LogInformation(" Phase 1: Searching forward from sync time..."); _logger.LogInformation(" Phase 1: Searching forward 12 hours from sync time...");
for (var minutesAhead = 0; minutesAhead <= 720; minutesAhead++) // 720 minutes = 12 hours for (var minutesAhead = 0; minutesAhead <= 720; minutesAhead++) // 720 minutes = 12 hours
{ {
if (cancellationToken.IsCancellationRequested) break; if (cancellationToken.IsCancellationRequested) break;
@@ -361,11 +361,11 @@ public class SpotifyMissingTracksFetcher : BackgroundService
} }
} }
// Then search backwards 12 hours from sync time // Then search backwards 24 hours from sync time to catch yesterday's file
if (!found) if (!found)
{ {
_logger.LogInformation(" Phase 2: Searching backward from sync time..."); _logger.LogInformation(" Phase 2: Searching backward 24 hours from sync time...");
for (var minutesBehind = 1; minutesBehind <= 720; minutesBehind++) for (var minutesBehind = 1; minutesBehind <= 1440; minutesBehind++) // 1440 minutes = 24 hours
{ {
if (cancellationToken.IsCancellationRequested) break; if (cancellationToken.IsCancellationRequested) break;
@@ -386,7 +386,7 @@ public class SpotifyMissingTracksFetcher : BackgroundService
if (!found) if (!found)
{ {
_logger.LogWarning(" ✗ Could not find missing tracks file in ±12 hour window"); _logger.LogWarning(" ✗ Could not find missing tracks file (searched +12h/-24h window)");
} }
} }