isomorphic-git / lightning-fs

A lean and fast 'fs' for the browser
MIT License
476 stars 47 forks source link

Compare-and-swap like operation #101

Closed manuel closed 1 year ago

manuel commented 1 year 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 1 year ago

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