feat(12-01): implement library CRUD methods and orphan cleanup pipeline

- Add AddLibrary, RenameLibrary, RemoveLibrary, GetRemovalImpact methods
- RemoveLibrary follows exact order: phantom populate → delete audio_files → orphan cleanup → commit → FTS5 rebuild → cover art file cleanup → queue compact → events
- Add cancelLibraryScan and currentTrackBelongsToLibrary helpers
- Add RemovalHooks type and removalHooks field on Library struct
- Add LibraryAdded, LibraryRenamed, LibraryRemoved event constants
- Regenerate frontend events.ts with new CRUD events
- All hand-crafted SQL has SAFETY comments per project convention
- Dual artist_credit FK check (recordings + release_groups) for orphan cleanup
This commit is contained in:
2026-03-12 19:37:07 -04:00
parent e97b849602
commit bd44f8306c
4 changed files with 541 additions and 0 deletions
+4
View File
@@ -93,6 +93,10 @@ type Library struct {
scanQueue []scanQueueEntry
currentScanLibraryID int64
currentScanLibraryName string
// removalHooks holds callbacks for cross-cutting concerns during
// library removal (e.g. stopping playback, compacting queue).
removalHooks RemovalHooks
}
// SetRescanHooks provides optional hooks for cross-cutting