From 2315d6ab9febe3849ac419df2bc5849f65dbe3ce Mon Sep 17 00:00:00 2001 From: Josh Patra Date: Mon, 2 Feb 2026 13:05:36 -0500 Subject: [PATCH] reduce overlapping runs --- allstarr/Services/Spotify/SpotifyTrackMatchingService.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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); } }