Feed preference writes can overwrite concurrent changes #24

Closed
opened 2026-06-18 00:02:10 +00:00 by starsetbyte · 1 comment
Owner

Problem

putPreferences replaces complete array from cached snapshot. Other client's changes overwritten.

Proposed fix

Fetch latest immediately before write.

Source: Codex code review — data #3

## Problem putPreferences replaces complete array from cached snapshot. Other client's changes overwritten. ## Proposed fix Fetch latest immediately before write. Source: Codex code review — data #3
Author
Owner

Already fixed on main by PR #25 (codex/fix-feed-preference-race).

FeedPreferencesRepository.syncToServer() now fetches a fresh snapshot via fetchPreferencesSnapshot() immediately before the putPreferences write, splices only the updated savedFeedsPrefV2 into the latest array, and preserves all non-feed items (val nonFeedItems = latestSavedItems.filter { it.type != "feed" }) so another client's concurrent changes survive. A syncMutex serializes concurrent syncs from this app.

Covered by FeedPreferencesRepositoryTest:

  • sync fetches latest preferences and preserves concurrent unrelated changes
  • sync preserves non-feed saved items from latest snapshot
  • concurrent sync test

Verified green on main just now. Closing as completed.

Already fixed on `main` by PR #25 (`codex/fix-feed-preference-race`). `FeedPreferencesRepository.syncToServer()` now fetches a fresh snapshot via `fetchPreferencesSnapshot()` immediately before the `putPreferences` write, splices only the updated `savedFeedsPrefV2` into the latest array, and preserves all non-feed items (`val nonFeedItems = latestSavedItems.filter { it.type != "feed" }`) so another client's concurrent changes survive. A `syncMutex` serializes concurrent syncs from this app. Covered by `FeedPreferencesRepositoryTest`: - `sync fetches latest preferences and preserves concurrent unrelated changes` - `sync preserves non-feed saved items from latest snapshot` - concurrent sync test Verified green on `main` just now. Closing as completed.
Sign in to join this conversation.
No description provided.