From 5d5ed486c4962a57d74a5d2044b0191435a560f0 Mon Sep 17 00:00:00 2001 From: dev Date: Wed, 24 Jun 2026 21:24:54 +0200 Subject: [PATCH] fix(quality): repair two PR #896 merge blockers #1 DB init crash: the idx_lh_verification_status index was created before the ALTER TABLE that adds the column, so a fresh library_history (every existing install + clean checkouts) died on startup with "no such column: verification_status". Move the index after the column migration. #2 #652 quarantine loop returns: the rewritten filter_results_by_quality_preference dropped the _drop_quarantined_sources() pre-filter, letting a previously-quarantined (user, file) win the picker again and re-quarantine forever. Re-wire it at the top of the method. Co-Authored-By: Claude Opus 4.8 --- core/soulseek_client.py | 7 +++++++ database/music_database.py | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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