From 7936c23f730d92f259aa8df8630057ec186a7522 Mon Sep 17 00:00:00 2001 From: Broque Thomas Date: Wed, 19 Nov 2025 20:10:39 -0800 Subject: [PATCH] Update web_server.py --- web_server.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/web_server.py b/web_server.py index 4c233f2b..b3c3afcf 100644 --- a/web_server.py +++ b/web_server.py @@ -7825,11 +7825,21 @@ def get_wishlist_tracks(): from core.wishlist_service import get_wishlist_service from database.music_database import MusicDatabase - # Clean duplicates before fetching (runs automatically on every fetch) - db = MusicDatabase() - duplicates_removed = db.remove_wishlist_duplicates() - if duplicates_removed > 0: - print(f"🧹 Cleaned {duplicates_removed} duplicate tracks from wishlist") + # Clean duplicates ONLY if no active wishlist download is running + # This prevents count mismatches during active downloads + with tasks_lock: + wishlist_batch_active = any( + batch.get('playlist_id') == 'wishlist' and batch.get('phase') in ['analysis', 'downloading'] + for batch in download_batches.values() + ) + + if not wishlist_batch_active: + db = MusicDatabase() + duplicates_removed = db.remove_wishlist_duplicates() + if duplicates_removed > 0: + print(f"🧹 Cleaned {duplicates_removed} duplicate tracks from wishlist") + else: + print(f"⏸️ Skipping wishlist duplicate cleanup - download in progress") wishlist_service = get_wishlist_service() raw_tracks = wishlist_service.get_wishlist_tracks_for_download()