refactor: drop code nothing calls, and the sync log rows no app reads (#8002)
release / go (push) Successful in 1m56s
release / web (push) Successful in 1m18s
release / govulncheck (push) Successful in 19s
release / integration (push) Successful in 4m0s
release / android (push) Successful in 4m20s
release / Build signed APK (push) Successful in 4m52s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 25s
release / Verify release artifacts (tag releases only) (push) Skipped

- library.ProbeDurationMs and IsAudioFile, and db.MigrationsFS, had no
  callers.
- The delta sync logged and hydrated like and playlist changes on every
  like, playlist edit and duplicate merge, including a GetPlaylistsByIDs
  query per sync. Android applies only artists, albums and tracks, and
  the web doesn't sync; likes and playlists reach both through their own
  endpoints and live events. The like and playlist-entry deletes also
  went to every caller unscoped, user ids included. They are no longer
  written or served, and migration 0112 clears the rows already logged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 12:52:35 -05:00
co-authored by Claude Opus 5.5
parent 39fa740bff
commit 58fb2bbe9d
16 changed files with 29 additions and 350 deletions
-19
View File
@@ -11,21 +11,8 @@ import (
"git.fabledsword.com/bvandeusen/minstrel/internal/apierror"
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
"git.fabledsword.com/bvandeusen/minstrel/internal/playevents"
syncpkg "git.fabledsword.com/bvandeusen/minstrel/internal/sync"
)
// logLikeChange writes a library_changes row for a like / unlike. Best-
// effort: a failure here means the next sync may miss the row, but the
// HTTP response still succeeds. Cheap consequence — the user's other
// device sees the like once it manually pulls, or once a later like/unlike
// on the same entity emits a fresh log row.
func (h *handlers) logLikeChange(r *http.Request, et syncpkg.EntityType, userID, entityID pgtype.UUID, op syncpkg.Op) {
if err := syncpkg.LogChange(r.Context(), h.pool, et,
syncpkg.EncodeLikeID(syncpkg.FormatUUID(userID), syncpkg.FormatUUID(entityID)), op); err != nil {
h.logger.Warn("api: LogChange like", "kind", et, "user", userID, "entity", entityID, "err", err)
}
}
type likedIDsResponse struct {
TrackIDs []string `json:"track_ids"`
AlbumIDs []string `json:"album_ids"`
@@ -63,7 +50,6 @@ func (h *handlers) handleLikeTrack(w http.ResponseWriter, r *http.Request) {
// The like is on the song: every copy it reached changes on
// the client too.
for _, t := range withTrack(id, liked) {
h.logLikeChange(r, syncpkg.EntityLikeTrack, user.ID, t, syncpkg.OpUpsert)
h.publishLikeEvent(user.ID, t, "track", true)
}
w.WriteHeader(http.StatusNoContent)
@@ -102,7 +88,6 @@ func (h *handlers) handleUnlikeTrack(w http.ResponseWriter, r *http.Request) {
// Don't fail the response — soft-delete is best-effort.
}
for _, t := range withTrack(id, unliked) {
h.logLikeChange(r, syncpkg.EntityLikeTrack, user.ID, t, syncpkg.OpDelete)
h.publishLikeEvent(user.ID, t, "track", false)
}
w.WriteHeader(http.StatusNoContent)
@@ -132,7 +117,6 @@ func (h *handlers) handleLikeAlbum(w http.ResponseWriter, r *http.Request) {
writeErr(w, apierror.InternalMsg("insert failed", err))
return
}
h.logLikeChange(r, syncpkg.EntityLikeAlbum, user.ID, id, syncpkg.OpUpsert)
h.publishLikeEvent(user.ID, id, "album", true)
w.WriteHeader(http.StatusNoContent)
}
@@ -151,7 +135,6 @@ func (h *handlers) handleUnlikeAlbum(w http.ResponseWriter, r *http.Request) {
writeErr(w, apierror.InternalMsg("delete failed", err))
return
}
h.logLikeChange(r, syncpkg.EntityLikeAlbum, user.ID, id, syncpkg.OpDelete)
h.publishLikeEvent(user.ID, id, "album", false)
w.WriteHeader(http.StatusNoContent)
}
@@ -180,7 +163,6 @@ func (h *handlers) handleLikeArtist(w http.ResponseWriter, r *http.Request) {
writeErr(w, apierror.InternalMsg("insert failed", err))
return
}
h.logLikeChange(r, syncpkg.EntityLikeArtist, user.ID, id, syncpkg.OpUpsert)
h.publishLikeEvent(user.ID, id, "artist", true)
w.WriteHeader(http.StatusNoContent)
}
@@ -199,7 +181,6 @@ func (h *handlers) handleUnlikeArtist(w http.ResponseWriter, r *http.Request) {
writeErr(w, apierror.InternalMsg("delete failed", err))
return
}
h.logLikeChange(r, syncpkg.EntityLikeArtist, user.ID, id, syncpkg.OpDelete)
h.publishLikeEvent(user.ID, id, "artist", false)
w.WriteHeader(http.StatusNoContent)
}