#file-lock #lock #locking #fs #fs-file

fslock-guard

Wrapper around a lockfile with unlock-on-drop semantics

7 releases

0.2.0 Sep 30, 2024
0.1.5 Sep 3, 2024
0.1.4 Aug 1, 2024
0.1.3 Jun 5, 2024
0.1.0 Feb 5, 2024

#238 in Filesystem

Download history 1008/week @ 2024-07-30 690/week @ 2024-08-06 255/week @ 2024-08-13 521/week @ 2024-08-20 361/week @ 2024-08-27 824/week @ 2024-09-03 280/week @ 2024-09-10 249/week @ 2024-09-17 974/week @ 2024-09-24 723/week @ 2024-10-01 218/week @ 2024-10-08 181/week @ 2024-10-15 279/week @ 2024-10-22 998/week @ 2024-10-29 611/week @ 2024-11-05 902/week @ 2024-11-12

2,840 downloads per month
Used in 30 crates (via tor-persist)

MIT/Apache

17KB
156 lines

fslock-guard — A guard object to ensure we have an exclusive lock to a file

This crate is a thin wrapper around fslock, which uses flock(2) or LockFileEx to acquire an advisory lock on the filesystem.

We add two features that fslock does not (currently) have:

  • We have a LockFileGuard type, which can be used to ensure that a lock is actually held until the guard is dropped.
  • We perform a post-lock check to make sure that our lockfile has not been removed and re-created on disk by someone else. This check makes it safe to remove lockfiles.

lib.rs:

Dependencies

~0.3–1MB
~19K SLoC