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
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:
@@ -21,9 +21,7 @@ import (
|
||||
// itself fails after the mutation succeeded, that mutation won't appear in
|
||||
// the change log until the entity is touched again.
|
||||
//
|
||||
// entityID is the string form of the row's primary key. For composite-key
|
||||
// entities (likes, playlist_tracks), use EncodeLikeID / EncodePlaylistTrackID
|
||||
// to produce stable strings. For pgtype.UUID values, use FormatUUID.
|
||||
// entityID is the row's UUID as a string; use FormatUUID.
|
||||
func LogChange(ctx context.Context, dbtx dbq.DBTX, entityType EntityType, entityID string, op Op) error {
|
||||
q := dbq.New(dbtx)
|
||||
if err := q.InsertLibraryChange(ctx, dbq.InsertLibraryChangeParams{
|
||||
@@ -83,16 +81,3 @@ func formatUUIDBytes(b [16]byte) string {
|
||||
}
|
||||
return string(out)
|
||||
}
|
||||
|
||||
// EncodeLikeID joins a user UUID and an entity UUID into the stable
|
||||
// composite identifier used for like_* rows in library_changes. Both
|
||||
// sides are UUID strings so no escaping is needed.
|
||||
func EncodeLikeID(userID, entityID string) string {
|
||||
return userID + ":" + entityID
|
||||
}
|
||||
|
||||
// EncodePlaylistTrackID joins a playlist UUID and a track UUID into the
|
||||
// stable composite identifier used for playlist_track rows.
|
||||
func EncodePlaylistTrackID(playlistID, trackID string) string {
|
||||
return playlistID + ":" + trackID
|
||||
}
|
||||
|
||||
@@ -49,12 +49,3 @@ func TestLogChange_RollbackDoesNotPersist(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, cursorBefore, cursorAfter, "rollback must not advance cursor")
|
||||
}
|
||||
|
||||
// Pure unit tests — run even with -short.
|
||||
func TestEncodeLikeID(t *testing.T) {
|
||||
require.Equal(t, "u1:t2", sync.EncodeLikeID("u1", "t2"))
|
||||
}
|
||||
|
||||
func TestEncodePlaylistTrackID(t *testing.T) {
|
||||
require.Equal(t, "p1:t2", sync.EncodePlaylistTrackID("p1", "t2"))
|
||||
}
|
||||
|
||||
+7
-10
@@ -8,19 +8,16 @@
|
||||
package sync
|
||||
|
||||
// EntityType enumerates the entity kinds whose mutations are tracked
|
||||
// by the library_changes log. Values must stay in sync with the CHECK
|
||||
// constraint on library_changes.entity_type.
|
||||
// by the library_changes log: the shared library, the same for every
|
||||
// listener. The CHECK constraint on library_changes.entity_type also admits
|
||||
// like_* and playlist* values, which older servers wrote and an older backup
|
||||
// may still carry; nothing writes or reads them.
|
||||
type EntityType string
|
||||
|
||||
const (
|
||||
EntityArtist EntityType = "artist"
|
||||
EntityAlbum EntityType = "album"
|
||||
EntityTrack EntityType = "track"
|
||||
EntityLikeTrack EntityType = "like_track"
|
||||
EntityLikeAlbum EntityType = "like_album"
|
||||
EntityLikeArtist EntityType = "like_artist"
|
||||
EntityPlaylist EntityType = "playlist"
|
||||
EntityPlaylistTrack EntityType = "playlist_track"
|
||||
EntityArtist EntityType = "artist"
|
||||
EntityAlbum EntityType = "album"
|
||||
EntityTrack EntityType = "track"
|
||||
)
|
||||
|
||||
// Op is upsert or delete. Matches the CHECK constraint on library_changes.op.
|
||||
|
||||
Reference in New Issue
Block a user