diff --git a/allstarr/Services/Spotify/SpotifyTrackMatchingService.cs b/allstarr/Services/Spotify/SpotifyTrackMatchingService.cs index 74df99b..4a921da 100644 --- a/allstarr/Services/Spotify/SpotifyTrackMatchingService.cs +++ b/allstarr/Services/Spotify/SpotifyTrackMatchingService.cs @@ -55,8 +55,12 @@ public class SpotifyTrackMatchingService : BackgroundService _logger.LogError(ex, "Error during startup track matching"); } + // Now start the periodic matching loop while (!stoppingToken.IsCancellationRequested) { + // Wait 30 minutes before next run + await Task.Delay(TimeSpan.FromMinutes(30), stoppingToken); + try { await MatchAllPlaylistsAsync(stoppingToken); @@ -65,9 +69,6 @@ public class SpotifyTrackMatchingService : BackgroundService { _logger.LogError(ex, "Error in track matching service"); } - - // Run every 30 minutes to catch new missing tracks - await Task.Delay(TimeSpan.FromMinutes(30), stoppingToken); } }