18 releases (10 major breaking)

13.1.1 Mar 14, 2024
13.0.0 Jan 20, 2024
12.0.1 Dec 30, 2023
11.0.1 Dec 6, 2023
3.0.2 Feb 17, 2023

#1 in #writable

Download history 99979/week @ 2024-01-05 102602/week @ 2024-01-12 112457/week @ 2024-01-19 120072/week @ 2024-01-26 130445/week @ 2024-02-02 129244/week @ 2024-02-09 128881/week @ 2024-02-16 132351/week @ 2024-02-23 139071/week @ 2024-03-01 133970/week @ 2024-03-08 150155/week @ 2024-03-15 152191/week @ 2024-03-22 143966/week @ 2024-03-29 139260/week @ 2024-04-05 140652/week @ 2024-04-12 117733/week @ 2024-04-19

565,041 downloads per month
Used in 196 crates (4 directly)

MIT/Apache

75KB
1.5K SLoC

Use lock-files in the way git does with auto-cleanup being the most notable feature.

  • writable lock files that can be committed to atomically replace the resource they lock
  • read-only markers that lock a resource without the intend to overwrite it
  • auto-removal of the lockfiles and intermediate directories on drop or on signal

lib.rs:

git-style registered lock files to make altering resources atomic.

In this model, reads are always atomic and can be performed directly while writes are facilitated by the locking mechanism implemented here. Locks are acquired atomically, then written to, to finally atomically overwrite the actual resource.

Lock files are wrapped gix-tempfile-handles and add the following:

  • consistent naming of lock files
  • block the thread (with timeout) or fail immediately if a lock cannot be obtained right away
  • commit lock files to atomically put them into the location of the originally locked file

Limitations

  • All limitations of gix-tempfile apply. A highlight of such a limitation is resource leakage which results in them being permanently locked unless there is user-intervention.
  • As the lock file is separate from the actual resource, locking is merely a convention rather than being enforced.

Dependencies

~3–13MB
~184K SLoC