perf(12-02): skip FTS5 rebuild during library removal

Contentless FTS5 cannot delete individual rows, but stale entries are
filtered out by the JOIN against track_metadata in search queries.
The index is rebuilt on the next full rescan. Removes ~10s of overhead
for a 25K-track library removal.
This commit is contained in:
2026-03-14 10:24:49 -04:00
parent 890284ddb1
commit 30f4461e69
+6 -4
View File
@@ -437,10 +437,12 @@ func (l *Library) RemoveLibrary(id int64) (*RemovalSummary, error) {
committed = true
// 19. Post-commit: Rebuild FTS5 (cannot run inside transaction).
if err := l.db.RebuildSearchIndex(); err != nil {
l.logger.Error("could not rebuild search index after removal", "err", err)
}
// 19. FTS5 rebuild skipped — contentless FTS5 (content='') cannot
// delete individual rows, but stale entries are harmless: search
// queries JOIN against track_metadata which filters out deleted
// rows. The index is rebuilt on the next full rescan. Skipping
// avoids a costly full re-index of all remaining tracks (~10s for
// 25K tracks).
// 20. Post-commit: Delete orphaned cover art files.
for _, coverPath := range orphanedCoverArtPaths {