This review is from Crev, a distributed system for code reviews. To add your review, set up cargo-crev.

The current version of FileLock is 2.1.11.

1.1.20 (older version) Rating: Neutral + Unmaintained Thoroughness: High Understanding: High

by git.jcg.re/jcgruenhage/crev-proofs.git on 2021-05-21

As the README claims, this locks files using the fcntl libc method, and it provides locks for both read and write access. I've read the man pages for that thoroughly and compared it to the implementation of this crate, and at least the C part of it is nearly perfect. I would have named some things differently, but aside of that, this part is good as it stands. It always locks the whole file, uses the proper flags and in general looks good. As for the rust part.. well, that's where the problems begin. The Drop impl does unlock the file, but ignores the result of the unlocking (it calls .is_ok() on the Result and ignores the return value, which is an antipattern also present in all of the test cases). When aquiring an exclusive lock, it disables read access to the file, causing bad fd errors when trying to read anyway. Last but not least, this crate hasn't been updated for the 2018 edition, has tons of warning and is using the deprecated and unmaintained gcc crate. These problems are easily fixable, and where I'm using the crate, I'm using my fork which has all these problems fixed, but considering that the other 3 MRs of the last year haven't been fixed either, I have my doubts about this still being maintained. If upstream continues to not respond, I'll fork this and update my review with an alternative accordingly.


Crates in the crates.io registry are tarball snapshots uploaded by crates' publishers. The registry is not using crates' git repositories. There is absolutely no guarantee that the repository URL declared by the crate belongs to the crate, or that the code in the repository is the code inside the published tarball.

To review the actual code of the crate, it's best to use cargo crev open file-lock. Alternatively, you can download the tarball of file-lock v2.1.11 or view the source online.