#lock-files #lock #file #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

#786 in Filesystem

Download history 1622/week @ 2024-11-16 1671/week @ 2024-11-23 1365/week @ 2024-11-30 388/week @ 2024-12-07 292/week @ 2024-12-14 166/week @ 2024-12-21 149/week @ 2024-12-28 342/week @ 2025-01-04 454/week @ 2025-01-11 554/week @ 2025-01-18 341/week @ 2025-01-25 295/week @ 2025-02-01 570/week @ 2025-02-08 364/week @ 2025-02-15 497/week @ 2025-02-22 458/week @ 2025-03-01

1,984 downloads per month
Used in 10 crates (6 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

~22KB