One Sync Cycle, Step by Step

One Sync Cycle, Step by Step A workflow diagram generated by Archify. 01 / On this device 02 / At the sync location EX / The cycle stops here Prepare Read and merge Write and report Flush saves · unsaved edits are stored · On this device › Prepare Flush saves unsaved edits are stored Set up · backend and key check · On this device › Prepare Set up backend and key check Check first · compare fingerprints · On this device › Read and merge Check first compare fingerprints Merge · higher revision wins · On this device › Read and merge · tombstones kept Merge higher revision wins tombstones kept Save locally · marked not yet uploaded · On this device › Write and report Save locally marked not yet uploaded Report · status and conflicts · On this device › Write and report Report status and conflicts Read the copy · with its ETag · At the sync location › Read and merge Read the copy with its ETag Write lease · one writer at a time · At the sync location › Read and merge · renewed every 20s Write lease one writer at a time renewed every 20s Upload · refused if it moved · At the sync location › Write and report Upload refused if it moved Attachments · upload and download · At the sync location › Write and report Attachments upload and download Stop here · off, or nothing changed · The cycle stops here › Read and merge Stop here off, or nothing changed Run again soon · the next cycle retries · The cycle stops here › Write and report Run again soon the next cycle retries nothing changed something differs lease held then upload claim the lease another device won sync is off Legend What you see On-device step Gate or lock Retry later Local database Remote storage

Most cycles stop early

  • • A fingerprint is a short digest of a file. Two matching digests mean the file did not change.
  • • The check compares this device's own digests first, and on phones the whole remote copy second.
  • • When both sides match, the cycle ends without a download or an upload.

Why the local save comes first

  • • The merged result is saved on the device and marked as not yet uploaded.
  • • If the upload then fails, the marker survives a crash and the next cycle retries the same data.
  • • Retries back off from 5 seconds to 5 minutes, and after 12 attempts sync reports an error.

Two devices, one remote copy

  • • A lease file at the sync location lets only one device change the remote at a time.
  • • The upload also carries the tag the copy had when it was read, so a stale write is refused.
  • • A refused write, or an edit made on this device mid-cycle, simply requeues the cycle.