hyperdrive
hyperdrive copied to clipboard
Multiple device-local writers
Using https://github.com/joehand/dat-secret-storage, @joehand and I have been conspiring to share private key storage between Beaker and Dat CLI. That would be really handy for me, because then I could create a Dat in the CLI, then make changes within Beaker.
But! It looks like this creates a coordination problem of multiple writers. What we dont want to happen is have conflicting writes issued by Beaker and Dat-CLI.
Fortunately, it's not a distributed multiwriter situation, so I think we can solve it pretty simply:
- Add a lockfile to the centralized storage.
- Also store the current metadata seq number in centralized storage.
- Only allow writes if you can 1) acquire the lock, and 2) have the most recent files synced.
That said, we can easily run into edgecase problems. Suppose I start dat-cli, make updates to a pre-existing shared dat, close dat-cli, and then open Beaker. Beaker will never sync the recent changes, but it also wont be able to make updates on account of the metadata seq. Worse: what if the user deletes the dat-cli copy of the dat, and thus can never update the Beaker copy?