How it works
Each upload declares the revision it was based on. At commit, compare that base with the current revision, a check known as compare-and-set. A match publishes a new immutable version; a mismatch preserves the submitted bytes as a conflict copy or draft. The user may compare, merge when the file format permits it, or choose a version. Silent last-writer-wins, where the most recent upload replaces the rest, can destroy work.
Walk through it. A phone and a laptop both start from revision 12 while offline. The phone reconnects first: its base 12 matches, so it publishes 13. The laptop then submits base 12, which no longer matches, so its bytes become a separate copy beside 13. Dropbox does this with its “conflicted copy” files. The cost falls on people: copies pile up and someone must reconcile them. Last-writer-wins can be acceptable for data that is cheap to regenerate, such as cached thumbnails.
Retain revisions according to an explicit policy. Delta sync transfers changed blocks, but each manifest still needs enough references to reconstruct its revision. Shared blocks keep history cheap: ten revisions of a 100-block file, each changing one block, occupy 109 blocks rather than 1,000. Renames, moves, and deletions can also conflict. Stable IDs and deletion tombstones, records saying a file was deleted, prevent an offline copy from accidentally resurrecting a removed file. File sync is not a collaborative text protocol.
A phone and laptop both edit revision 12 offline. The phone publishes 13 first. What happens to the laptop edit?
Its expected base 12 conflicts with current 13. Preserve its bytes as a conflict copy or draft and offer explicit merge or choice.
Use this as a guide for self review; written answers are not graded.Keep in mind
- Compare base revision at commit.
- Keep both contents when automatic merge is unsafe.