feat(library): remove tracks from the library without touching the file

"Remove from library" deletes the audio_files row and records the path
as excluded, so the next scan does not import it again. Without the
exclusion the operation undoes itself on the next scan, which is worse
than not having it at all; the file on disk is never touched, which is
the promise the confirmation copy will make.

The soft scan compares the number of audio files on disk against the
number of rows, so both walks now skip excluded paths — otherwise the
two counts disagree forever and every launch queues a full scan of the
whole library. A full rescan clears the exclusions, which is the only
way back for a path removed by mistake until there is a UI for it.
This commit is contained in:
2026-08-13 13:04:59 -04:00
parent 91bab4e73e
commit acbe7c4676
20 changed files with 854 additions and 11 deletions
+9
View File
@@ -124,6 +124,15 @@ func (l *Library) clearLibraryTables() error {
return fmt.Errorf("could not clear queue tracks: %w", err)
}
// A full rescan is the "start over" button, and it is the only way
// back for a path removed from the library by mistake: the file is
// still on disk, but nothing else will ever import it again while
// its exclusion stands. Until there is a UI for managing the list,
// clearing it here is the escape hatch.
if err := txq.ClearExcludedPaths(l.ctx); err != nil {
return fmt.Errorf("could not clear excluded paths: %w", err)
}
// Preserve playlist tracks across rescan: populate phantom
// metadata for all linked tracks before audio_files are deleted.
// ON DELETE SET NULL will null out audio_file_id, converting them