From 37d325ee106d8497f0f477954d39f9f68f98e7ca Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Wed, 8 Apr 2026 16:19:48 -0700 Subject: [PATCH] Add "Remove from DB" option for dead file findings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dead file fix now prompts with two options: Re-download (existing behavior — adds to wishlist + deletes DB entry) or Remove from DB (just deletes the dead track record without re-downloading). Works for both single and bulk fix. Solves the issue where dismissing dead files didn't remove the underlying track record, causing them to reappear on every scan. --- core/repair_worker.py | 29 +++++++++++++++++++++- webui/static/script.js | 56 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 3 deletions(-) diff --git a/core/repair_worker.py b/core/repair_worker.py index fd3520ea..0d2fc573 100644 --- a/core/repair_worker.py +++ b/core/repair_worker.py @@ -823,9 +823,36 @@ class RepairWorker: return handler(entity_type, entity_id, file_path, details) def _fix_dead_file(self, entity_type, entity_id, file_path, details): - """Add dead file track to wishlist for re-download, then remove the dead DB entry.""" + """Fix a dead file reference. Action depends on details['_fix_action']: + 'redownload' (default) — add to wishlist + remove DB entry + 'remove' — just remove the dead DB entry without re-downloading + """ if not entity_id: return {'success': False, 'error': 'No track ID associated with this finding'} + + fix_action = details.get('_fix_action', 'redownload') + + # Simple removal — just delete the dead track record + if fix_action == 'remove': + conn = None + try: + conn = self.db._get_connection() + cursor = conn.cursor() + cursor.execute("SELECT title FROM tracks WHERE id = ?", (entity_id,)) + row = cursor.fetchone() + track_name = row['title'] if row else 'Unknown' + cursor.execute("DELETE FROM tracks WHERE id = ?", (entity_id,)) + conn.commit() + return {'success': True, 'action': 'removed', + 'message': f'Removed "{track_name}" from database'} + except Exception as e: + logger.error("Dead file removal failed for track %s: %s", entity_id, e) + return {'success': False, 'error': str(e)} + finally: + if conn: + conn.close() + + # Default: re-download flow conn = None try: conn = self.db._get_connection() diff --git a/webui/static/script.js b/webui/static/script.js index 22427901..b8a9bfb6 100644 --- a/webui/static/script.js +++ b/webui/static/script.js @@ -63005,6 +63005,11 @@ async function fixRepairFinding(id, findingType) { fixAction = await _promptOrphanAction(); if (!fixAction) return; // User cancelled } + // Dead files: re-download or just remove from DB + if (findingType === 'dead_file') { + fixAction = await _promptDeadFileAction(); + if (!fixAction) return; + } const card = document.querySelector(`.repair-finding-card[data-id="${id}"]`); const fixBtn = card ? card.querySelector('.repair-finding-btn.fix') : null; @@ -63073,6 +63078,39 @@ function _promptOrphanAction() { }); } +function _promptDeadFileAction() { + return new Promise(resolve => { + const overlay = document.createElement('div'); + overlay.className = 'modal-overlay'; + overlay.style.cssText = 'display:flex;align-items:center;justify-content:center;z-index:10000;'; + overlay.innerHTML = ` +