Update web_server.py
This commit is contained in:
parent
58388645d7
commit
7936c23f73
1 changed files with 15 additions and 5 deletions
|
|
@ -7825,11 +7825,21 @@ def get_wishlist_tracks():
|
||||||
from core.wishlist_service import get_wishlist_service
|
from core.wishlist_service import get_wishlist_service
|
||||||
from database.music_database import MusicDatabase
|
from database.music_database import MusicDatabase
|
||||||
|
|
||||||
# Clean duplicates before fetching (runs automatically on every fetch)
|
# Clean duplicates ONLY if no active wishlist download is running
|
||||||
db = MusicDatabase()
|
# This prevents count mismatches during active downloads
|
||||||
duplicates_removed = db.remove_wishlist_duplicates()
|
with tasks_lock:
|
||||||
if duplicates_removed > 0:
|
wishlist_batch_active = any(
|
||||||
print(f"🧹 Cleaned {duplicates_removed} duplicate tracks from wishlist")
|
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()
|
wishlist_service = get_wishlist_service()
|
||||||
raw_tracks = wishlist_service.get_wishlist_tracks_for_download()
|
raw_tracks = wishlist_service.get_wishlist_tracks_for_download()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue