diff --git a/core/soulseek_client.py b/core/soulseek_client.py index a5062585..9dfcedd0 100644 --- a/core/soulseek_client.py +++ b/core/soulseek_client.py @@ -2026,6 +2026,13 @@ class SoulseekClient(DownloadSourcePlugin): """ from database.music_database import MusicDatabase + if not results: + return [] + + # Issue #652: drop candidates on the quarantine record BEFORE ranking, + # so a previously-quarantined source can't win the quality picker by + # superior bitrate and re-trigger the same failed download in a loop. + results = self._drop_quarantined_sources(results) if not results: return [] diff --git a/database/music_database.py b/database/music_database.py index 3b6a17fb..492440d5 100644 --- a/database/music_database.py +++ b/database/music_database.py @@ -664,7 +664,6 @@ class MusicDatabase: """) cursor.execute("CREATE INDEX IF NOT EXISTS idx_lh_event_type ON library_history (event_type)") cursor.execute("CREATE INDEX IF NOT EXISTS idx_lh_created_at ON library_history (created_at DESC)") - cursor.execute("CREATE INDEX IF NOT EXISTS idx_lh_verification_status ON library_history (verification_status)") # Migration: add download_source column cursor.execute("PRAGMA table_info(library_history)") @@ -677,6 +676,12 @@ class MusicDatabase: cursor.execute(f"ALTER TABLE library_history ADD COLUMN {_col} TEXT") logger.info(f"Added {_col} column to library_history") + # Index on verification_status — MUST come after the ALTER above: + # on a fresh DB the base CREATE TABLE has no verification_status + # column, so indexing it before the migration adds it raises + # "no such column: verification_status" and aborts DB init. + cursor.execute("CREATE INDEX IF NOT EXISTS idx_lh_verification_status ON library_history (verification_status)") + # One-time backfill: derive verification_status for history rows # written before the column existed (or by pipeline exits that # missed it) from the acoustid_result those imports already