Stage 3 of 7 · Break it
Dropbox-Style File Sync Service: Make the file appear only when it is complete
The client knows the desired block hashes. Some blocks already exist; two are missing. The file must not become visible with missing data. The client may retry after an unknown number of successful writes.
What you need to know
Check
When should the service publish a new version manifest?The safe sequence is: authenticate and validate the expected current revision; upload missing blocks and wait for durable acknowledgements; conditionally commit the new manifest and append its journal row in one metadata transaction; then notify online devices. If the process crashes before commit, the previous version is still visible and the new blocks are harmless orphans. If it crashes after commit, every referenced block was already acknowledged as durable. Notifications follow the commit and can be retried.
The commit should compare the current file revision with the revision the client edited. This is a compare-and-swap: only one writer based on revision 12 can publish revision 13. A second writer gets a conflict response and can preserve its content as a separate version instead of silently replacing the winner.