siftlode/backend/app/plex
npeter83 5592f60e85 fix(plex): make watch import concurrency-safe (upsert), guard toggle
The Plex watch import inserted plex_states via per-row ORM add against a pre-read 'existing' set,
which is not safe when the enable call fires more than once while the multi-second import runs (the
toggle wasn't disabled during it): overlapping imports raced to INSERT the same (user_id, item_id)
rows and all but the first hit a UniqueViolation -> 500 (seen on prod). Rewrite the write path as a
chunked PostgreSQL UPSERT (on_conflict_do_update, rows de-duped by item_id) — idempotent and
concurrency-safe, Plex still wins on the intersection and Siftlode-only states are untouched.

Also disable the Settings toggle (and ignore its onChange) while a sync mutation is pending, so it
can't be fired repeatedly; adds a reusable 'disabled' prop to the Switch primitive.
2026-07-09 15:18:19 +02:00
..
__init__.py feat(plex): P0 backend foundations — catalog model, config, client 2026-07-05 01:35:08 +02:00
client.py feat(plex): Collections Phase 2 — admin collection editing (write-back to Plex) 2026-07-06 17:33:16 +02:00
paths.py feat(plex): P0 backend foundations — catalog model, config, client 2026-07-05 01:35:08 +02:00
stream.py feat(plex): multi-rendition audio (client-side switch) + reliable resume-on-F5 2026-07-08 22:25:03 +02:00
sync.py feat(plex): Collections Phase 2 — admin collection editing (write-back to Plex) 2026-07-06 17:33:16 +02:00
watch_sync.py fix(plex): make watch import concurrency-safe (upsert), guard toggle 2026-07-09 15:18:19 +02:00