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:
@@ -146,66 +146,8 @@ func TestLibrarySync_DeleteIsReflected(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLibrarySync_LikeRowScopedToUser(t *testing.T) {
|
||||
h, pool := testHandlers(t)
|
||||
truncateLibrary(t, pool)
|
||||
u := seedUser(t, pool, "alice", "x", false)
|
||||
other := seedUser(t, pool, "bob", "x", false)
|
||||
|
||||
// Two like_track rows: one for u, one for other. u's call should
|
||||
// see only their own row.
|
||||
ctx := context.Background()
|
||||
tx, _ := pool.Begin(ctx)
|
||||
_ = sync.LogChange(ctx, tx, sync.EntityLikeTrack,
|
||||
sync.EncodeLikeID(sync.FormatUUID(u.ID), "11111111-1111-1111-1111-111111111111"),
|
||||
sync.OpUpsert)
|
||||
_ = sync.LogChange(ctx, tx, sync.EntityLikeTrack,
|
||||
sync.EncodeLikeID(sync.FormatUUID(other.ID), "22222222-2222-2222-2222-222222222222"),
|
||||
sync.OpUpsert)
|
||||
_ = tx.Commit(ctx)
|
||||
|
||||
w := callLibrarySync(h, u, "0")
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d body = %s", w.Code, w.Body.String())
|
||||
}
|
||||
var body struct {
|
||||
Upserts map[string][]json.RawMessage `json:"upserts"`
|
||||
}
|
||||
if err := json.NewDecoder(w.Body).Decode(&body); err != nil {
|
||||
t.Fatalf("decode: %v", err)
|
||||
}
|
||||
got := body.Upserts["like_track"]
|
||||
if len(got) != 1 {
|
||||
t.Fatalf("expected 1 like row scoped to alice, got %d", len(got))
|
||||
}
|
||||
}
|
||||
|
||||
// Pure unit tests below — run even with -short.
|
||||
|
||||
func TestSplitOnce(t *testing.T) {
|
||||
cases := []struct {
|
||||
in, sep string
|
||||
want []string
|
||||
}{
|
||||
{"a:b", ":", []string{"a", "b"}},
|
||||
{"a:b:c", ":", []string{"a", "b:c"}},
|
||||
{"abc", ":", []string{"abc"}},
|
||||
{":x", ":", []string{"", "x"}},
|
||||
}
|
||||
for _, c := range cases {
|
||||
got := splitOnce(c.in, c.sep)
|
||||
if len(got) != len(c.want) {
|
||||
t.Errorf("splitOnce(%q,%q): len got=%d want=%d", c.in, c.sep, len(got), len(c.want))
|
||||
continue
|
||||
}
|
||||
for i := range got {
|
||||
if got[i] != c.want[i] {
|
||||
t.Errorf("splitOnce(%q,%q)[%d] = %q want %q", c.in, c.sep, i, got[i], c.want[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A server restored from an older backup has handed out fewer cursors than an
|
||||
// app remembers; the app is told to reset rather than wait for ids it would
|
||||
// then skip. A compacted log is not that: the cursor the server handed out
|
||||
|
||||
Reference in New Issue
Block a user