DEV Community

Cover image for Two people, one folder, and no lock anywhere
Marius-Florin Cristian
Marius-Florin Cristian

Posted on Originally published at keibisoft.com AI-assisted

Two people, one folder, and no lock anywhere

KEIBIDROP mounts a folder on two machines. Both sides can write to it. And it does this without any server, nor taking an authoritative lock.

Concurrent edits are quite hard and we resolve them by comparing timestamps and the older save is overwritten without being announced.

So every change done through keibidrop now carries one extra number: the newest version of that file that the sender actually held when they started editing. If a save arrives with a
number lower than the version I hold, then I know that the sender had not seen my version and the two edits were concurrent.The newer
save keeps the path, the older one is written beside it as
name.conflict-TIMESTAMP.ext, and that file syncs to both machines.

Over a real link, Bucharest to Timisoara, ten out of ten steps converged in 0.55 to 0.63 s, and the conflict file reached both machines 0.02 s later.

Write-up, including why we did not build a CRDT:
Two people, one folder, and no lock anywhere

Top comments (0)