RemoveFromLibrary deletes the audio_files rows the way the scan's own orphan cleanup does and records each path in excluded_paths. The exclusion is not an enhancement: without it the next scan finds the file, sees no row and imports it again, so the button undoes itself. The soft scan compares files on disk against rows in the database, so surveyAudioFiles and countAudioFiles both take the exclusion set — otherwise an excluded path makes the two disagree forever and queues a full scan on every launch. Deleting a row cascades to queue_tracks, so the removal calls the same CompactQueue hook RemoveLibrary does. Also lands the requested badge: library-status-indicator is a button again where it can act, utils/library-status.ts states once what owning and wanting mean, and the long-declared queued state finally has a producer. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UDCbcCZQepnpSQYJ6SxxZm
26 lines
1.1 KiB
SQL
26 lines
1.1 KiB
SQL
-- Paths the user has removed from the library, which the scanner must
|
|
-- not import again.
|
|
--
|
|
-- "Remove from library" deletes the audio_files row and leaves the file
|
|
-- on disk. Without this table the next scan finds the file, sees no
|
|
-- row for it, and imports it again — so the exclusion is not an
|
|
-- enhancement, it is what makes the operation mean anything.
|
|
--
|
|
-- A row is keyed by (library_id, file_path) rather than by audio_file
|
|
-- id, because the row it names has just been deleted. ON DELETE
|
|
-- CASCADE from libraries means removing a library takes its exclusions
|
|
-- with it; a full rescan clears the table outright, which is the only
|
|
-- way back for a path removed by mistake until there is a UI for it.
|
|
|
|
CREATE TABLE IF NOT EXISTS excluded_paths (
|
|
id INTEGER PRIMARY KEY,
|
|
library_id INTEGER NOT NULL,
|
|
file_path TEXT NOT NULL,
|
|
excluded_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
UNIQUE(library_id, file_path),
|
|
FOREIGN KEY(library_id) REFERENCES libraries(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_excluded_paths_library
|
|
ON excluded_paths(library_id);
|