An append that reached the server but whose reply never reached the
phone stayed in the offline queue and was sent again, and since an
append is an action, the song landed twice. Android now names each
append with a request id, carried by the live send and its queued row
alike; POST /api/playlists/{id}/tracks takes it as request_id, and the
server records it per playlist in the append's own transaction
(playlist_append_requests, pruned after 30 days). A send whose id is
already recorded changes nothing; a failed append rolls its id back
with it. Without an id an append behaves as before, so queued rows
from older builds and Subsonic clients are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
14 lines
764 B
SQL
14 lines
764 B
SQL
-- An append the phone sent but never heard back about (a timeout, the app
|
|
-- killed mid-request) stays in its offline queue and is sent again. An
|
|
-- append is an action, not a state, so the second send would add the songs
|
|
-- a second time. The phone now names each append with a request id, and
|
|
-- the server keeps the ids it has applied here: a send whose id is already
|
|
-- recorded for the playlist changes nothing. Rows older than 30 days are
|
|
-- pruned as new appends arrive; a queued write is replayed long before that.
|
|
CREATE TABLE playlist_append_requests (
|
|
playlist_id uuid NOT NULL REFERENCES playlists(id) ON DELETE CASCADE,
|
|
request_id uuid NOT NULL,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
PRIMARY KEY (playlist_id, request_id)
|
|
);
|