From f9450b4fea16b5f59bcec14fff050103ba217637 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Sun, 12 Apr 2026 16:33:08 -0700 Subject: [PATCH] Purge cached tracks with junk artist names on first v2.3 startup One-time migration deletes metadata cache entries where artist_name is null, empty, 'unknown', 'unknown artist', etc. The cache gate now prevents new junk entries, but existing poisoned data from before the fix needs cleaning so users don't keep getting Unknown Artist from stale cache hits. --- database/music_database.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/database/music_database.py b/database/music_database.py index 2db8751d..a07225d9 100644 --- a/database/music_database.py +++ b/database/music_database.py @@ -660,6 +660,23 @@ class MusicDatabase: except Exception: pass + # One-time migration: purge cached tracks/albums with junk artist names. + # The cache gate now rejects these, but existing entries need cleaning. + try: + cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='_cache_junk_artist_purged'") + if not cursor.fetchone(): + cursor.execute("""DELETE FROM metadata_cache_entities + WHERE entity_type IN ('track', 'album') + AND (artist_name IS NULL + OR TRIM(artist_name) = '' + OR LOWER(TRIM(artist_name)) IN ('unknown', 'unknown artist', 'none', 'null'))""") + purged = cursor.rowcount + cursor.execute("CREATE TABLE _cache_junk_artist_purged (applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)") + if purged > 0: + logger.info(f"Purged {purged} cached tracks/albums with junk artist names") + except Exception: + pass + conn.commit() logger.info("Database initialized successfully")