#lock-files #create #locking

lockfile

Create lockfiles that remove themselves when they are dropped

6 releases (3 breaking)

0.4.0 Sep 12, 2022
0.3.0 Sep 9, 2021
0.2.2 Feb 19, 2020
0.2.1 Jun 3, 2018
0.1.0 May 28, 2018

#967 in Filesystem

Download history 243/week @ 2025-05-23 247/week @ 2025-05-30 313/week @ 2025-06-06 606/week @ 2025-06-13 1021/week @ 2025-06-20 366/week @ 2025-06-27 446/week @ 2025-07-04 439/week @ 2025-07-11 312/week @ 2025-07-18 641/week @ 2025-07-25 719/week @ 2025-08-01 819/week @ 2025-08-08 646/week @ 2025-08-15 1184/week @ 2025-08-22 1235/week @ 2025-08-29 1025/week @ 2025-09-05

4,274 downloads per month
Used in 11 crates (7 directly)

MIT/Apache-2.0/ISC

11KB
175 lines

lockfile-rs

A (work in progress) library for creating and locking lockfiles.

See tests::smoke for a guide to how it works.


lib.rs:

This crate provides a lockfile struct that marks a location in the filesystem as locked.

A lock is conceptually created when the file is created, and released when it is deleted.

If the file is already present, the create function will fail.

Examples

use lockfile::Lockfile;

const PATH: &str = "/tmp/some_file/s8329894";
let lockfile = Lockfile::create(PATH).unwrap();
assert_eq!(lockfile.path(), Path::new(PATH));
lockfile.release()?; // or just let the lockfile be dropped
// File has been unlinked/deleted.
assert_eq!(fs::metadata(PATH).unwrap_err().kind(),
           io::ErrorKind::NotFound);

Dependencies

~25KB