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
+1 -9
View File
@@ -411,17 +411,9 @@ func linkSong(ctx context.Context, pool *pgxpool.Pool, ids []pgtype.UUID) (bool,
if link.Moved == 0 {
return false, nil
}
added, err := tq.ShareSongLikes(ctx, link.SongKey)
if err != nil {
if _, err := tq.ShareSongLikes(ctx, link.SongKey); err != nil {
return false, fmt.Errorf("share likes: %w", err)
}
likeIDs := make([]string, len(added))
for i, a := range added {
likeIDs[i] = syncpkg.EncodeLikeID(syncpkg.FormatUUID(a.UserID), syncpkg.FormatUUID(a.TrackID))
}
if err := syncpkg.LogChanges(ctx, tx, syncpkg.EntityLikeTrack, likeIDs, syncpkg.OpUpsert); err != nil {
return false, fmt.Errorf("log shared likes: %w", err)
}
return true, tx.Commit(ctx)
}
-10
View File
@@ -799,16 +799,6 @@ func probeDurationMs(ctx context.Context, path string) (int32, error) {
return int32(ms), nil
}
// ProbeDurationMs is a file's length in milliseconds, read by ffprobe.
func ProbeDurationMs(ctx context.Context, path string) (int32, error) {
return probeDurationMs(ctx, path)
}
// IsAudioFile reports whether the scanner reads a file with this name.
func IsAudioFile(path string) bool {
return audioExtensions[strings.ToLower(filepath.Ext(path))]
}
// Roots are the folders the scanner reads: the library.
func (s *Scanner) Roots() []string {
if s == nil {
-9
View File
@@ -99,15 +99,6 @@ func TestCrossReleaseCopiesCountAsOneSong_Integration(t *testing.T) {
if len(liked) != 2 {
t.Errorf("liked track ids = %d, want both copies", len(liked))
}
var logged int
if err := pool.QueryRow(ctx,
`SELECT count(*) FROM library_changes WHERE entity_type = 'like_track' AND op = 'upsert'`,
).Scan(&logged); err != nil {
t.Fatal(err)
}
if logged != 1 {
t.Errorf("logged %d shared likes, want 1 (the album cut)", logged)
}
if n, err := q.CountLikedTracks(ctx, f.user.ID); err != nil || n != 1 {
t.Errorf("CountLikedTracks = %d (%v), want 1 song", n, err)
}