Skip to content

0.5.0-pre.26 - stop list duplication on sync

Pre-release
Pre-release

Choose a tag to compare

@onlymykazari onlymykazari released this 11 Jul 13:16

Fix

Lists no longer duplicate after every sync ("4 lists become 8, then 12").

Root cause

A three-way race between pull, our own file writes, and the vault event handler:

  1. Pull replaces `localBoard.lists` wholesale with fresh uids where needed.
  2. pullCards then calls `writeCardFile` per refreshed card (pre.22 addition), triggering vault modify events.
  3. Those events hit the 250ms folder-sync debounce, which runs `reconcileListsFromIndex`.
  4. `reconcileListsFromIndex` reads the stale index file's list meta (pull never rewrites it), sees uids that don't exist in current `board.lists`, and re-creates them as empty lists.

Result: every sync resurrects the previous generation of list uids, so a 4-list remote board becomes 8 locally, then 12, etc.

Fix

At the end of pull, re-run `writeBoardIndexFile` for every bound board, wrapped in the plugin's `reconciling` guard so our own writes don't fire the folder-sync debounce a second time. This keeps the on-disk list meta in lockstep with in-memory `data.boards`, making `reconcileListsFromIndex` a no-op after the vault event fires.

Test

  1. Update via BRAT to 0.5.0-pre.26
  2. Sync now → the extra empty lists should collapse back to the real 4 (they were dropped in memory by pull all along; they came back only via the vault event)
  3. Sync again → count stays stable at 4