fix(maintenance): bound search_clicks and lyrics_index, clear stale queue source
CI / check (push) Skipped
CI / e2e (push) Skipped
CI / check (pull_request) Failing after 1m3s
CI / e2e (pull_request) Skipped

Three unbounded or stale surfaces, each small on its own:

- lyrics_index rows were never pruned on track removal, so the FTS index
  grew forever. Delete the entry where the library search FTS entry is
  already deleted, on the orphan and RemoveFromLibrary paths.
- search_clicks had no ceiling; age out ranking rows after a retention
  window via a daily janitor job.
- queue.source_* kept a "Playing from X" label after its playlist was
  deleted. Drop the source when the queue's own playlist goes, wired
  through a playlist-service hook like Library.SetRemovalHooks.

Closes #249
This commit is contained in:
2026-09-09 10:22:57 -04:00
parent 6aeac42a46
commit 4e5c6b9f7a
9 changed files with 195 additions and 5 deletions
+13 -1
View File
@@ -968,7 +968,7 @@ func (l *Library) scanInternal(
}
}
// Remove from FTS5 search index.
// Remove from FTS5 search index and the lyrics index.
if err := l.db.DeleteSearchIndex(
audioFile.ID,
); err != nil {
@@ -981,6 +981,18 @@ func (l *Library) scanInternal(
metrics.addWarning(path, "orphan", err)
}
if err := l.db.DeleteLyricsIndex(
audioFile.ID,
); err != nil {
l.logger.Warn(
"failed to delete lyrics index entry for orphan",
"id", audioFile.ID,
"err", err,
)
metrics.addWarning(path, "orphan", err)
}
removed.Add(1)
return true
+5
View File
@@ -127,6 +127,11 @@ func (l *Library) RemoveFromLibrary(filePaths []string) (*RemovalResult, error)
l.logger.Warn("could not delete FTS entry for removed track",
"path", row.FilePath, "id", row.ID, "err", err)
}
if err := l.db.DeleteLyricsIndex(row.ID); err != nil {
l.logger.Warn("could not delete lyrics index entry for removed track",
"path", row.FilePath, "id", row.ID, "err", err)
}
}
// Deleting an audio_files row cascades to queue_tracks, so the