isomorphic-git / lightning-fs

A lean and fast 'fs' for the browser
MIT License
493 stars 48 forks source link

Compare-and-swap like operation #101

Closed manuel closed 2 years ago

manuel commented 2 years ago

Hello, first of all thank you for the great libraries lightning-fs and isomorphic-git!

I am interested in implementing something like Git's push --force-with-lease which allows you to require that a ref has a particular hash before changing it (to prevent multi-tab conflicts), similar to how a compare-and-swap works.

How tricky do you think would it be to do something like this, due to the caching Lightning-FS does? Would an approach of grabbing a Web Lock, syncing the FS, and doing a read and write (while holding the lock) work?

jcubic commented 2 years ago

I have no clue, maybe just try your idea out and see if it works.