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
+4 -22
View File
@@ -187,7 +187,6 @@ func foldTrackInto(
ctx context.Context, tq *dbq.Queries, survivorID, loserID pgtype.UUID, changes *mergeChanges,
) (foldResult, error) {
var f foldResult
survivorKey := syncpkg.FormatUUID(survivorID)
loserKey := syncpkg.FormatUUID(loserID)
n, err := tq.MergeRepointPlayEvents(ctx, dbq.MergeRepointPlayEventsParams{SurvivorID: survivorID, LoserID: loserID})
@@ -212,21 +211,13 @@ func foldTrackInto(
return f, fmt.Errorf("move playlist entries: %w", err)
}
f.PlaylistEntries = len(playlists)
for _, pl := range playlists {
plKey := syncpkg.FormatUUID(pl)
changes.playlistDelete(syncpkg.EncodePlaylistTrackID(plKey, loserKey))
changes.playlistUpsert(syncpkg.EncodePlaylistTrackID(plKey, survivorKey))
}
users, err := tq.MergeCopyGeneralLikes(ctx, dbq.MergeCopyGeneralLikesParams{SurvivorID: survivorID, LoserID: loserID})
if err != nil {
return f, fmt.Errorf("move likes: %w", err)
}
for _, u := range users {
userKey := syncpkg.FormatUUID(u)
f.Likers = append(f.Likers, userKey)
changes.likeDelete(syncpkg.EncodeLikeID(userKey, loserKey))
changes.likeUpsert(syncpkg.EncodeLikeID(userKey, survivorKey))
f.Likers = append(f.Likers, syncpkg.FormatUUID(u))
}
if _, err := tq.MergeCopyTrackTags(ctx, dbq.MergeCopyTrackTagsParams{SurvivorID: survivorID, LoserID: loserID}); err != nil {
@@ -297,10 +288,9 @@ func mergedCopyOf(m dbq.ListDuplicateGroupMergeMembersRow) MergedCopy {
}
// mergeChanges collects the sync-log entries a merge owes clients' caches, each
// once: a user who liked two removed copies still gets one upsert for the
// survivor.
// once: the removed copies' tracks.
type mergeChanges struct {
tracks, likeDeletes, likeUpserts, playlistDeletes, playlistUpserts map[string]struct{}
tracks map[string]struct{}
}
func addTo(set *map[string]struct{}, id string) {
@@ -310,11 +300,7 @@ func addTo(set *map[string]struct{}, id string) {
(*set)[id] = struct{}{}
}
func (c *mergeChanges) trackDelete(id string) { addTo(&c.tracks, id) }
func (c *mergeChanges) likeDelete(id string) { addTo(&c.likeDeletes, id) }
func (c *mergeChanges) likeUpsert(id string) { addTo(&c.likeUpserts, id) }
func (c *mergeChanges) playlistDelete(id string) { addTo(&c.playlistDeletes, id) }
func (c *mergeChanges) playlistUpsert(id string) { addTo(&c.playlistUpserts, id) }
func (c *mergeChanges) trackDelete(id string) { addTo(&c.tracks, id) }
func (c *mergeChanges) log(ctx context.Context, tx pgx.Tx) error {
for _, entry := range []struct {
@@ -323,10 +309,6 @@ func (c *mergeChanges) log(ctx context.Context, tx pgx.Tx) error {
op syncpkg.Op
}{
{syncpkg.EntityTrack, c.tracks, syncpkg.OpDelete},
{syncpkg.EntityLikeTrack, c.likeDeletes, syncpkg.OpDelete},
{syncpkg.EntityLikeTrack, c.likeUpserts, syncpkg.OpUpsert},
{syncpkg.EntityPlaylistTrack, c.playlistDeletes, syncpkg.OpDelete},
{syncpkg.EntityPlaylistTrack, c.playlistUpserts, syncpkg.OpUpsert},
} {
if len(entry.ids) == 0 {
continue