~zethra/file-locker

90d32e4328b437705dc20ea6a8d5764c8c670e61 — Sashanoraa 6 months ago d49d720
Updated nix

Signed-off-by: Sashanoraa <sasha@noraa.gay>
2 files changed, 18 insertions(+), 17 deletions(-)

M Cargo.toml
M src/lib.rs
M Cargo.toml => Cargo.toml +5 -7
@@ 1,18 1,16 @@
[package]
name        = "file-locker"
version     = "1.0.5"
authors     = ["Ben Aaron Goldberg <ben@benaaron.dev>", "Alfie John <alfie@alfie.wtf>", "Sebastian Thiel <byronimo@gmail.com>"]
authors     = ["Sashanoraa <sasha@noraa.gay>", "Alfie John <alfie@alfie.wtf>", "Sebastian Thiel <byronimo@gmail.com>"]
description = "File locking via POSIX advisory record locks"
license     = "MIT"
edition     = "2018"
categories  = ["os", "os::unix-apis"]
keywords    = ["linux"]
keywords    = ["linux", "file", "lock"]

documentation = "http://docs.rs/file-locker/"
homepage      = "https://crates.io/crates/file-locker"
repository    = "https://sr.ht/~zethra/file-locker/"
readme        = "README.md"
homepage      = "https://sr.ht/~zethra/file-locker/"
repository    = "https://git.sr.ht/~zethra/file-locker/"
include       = ["src/lib.rs", "LICENSE", "README.md"]

[dependencies]
nix = "0.17.0"
nix = "0.23"

M src/lib.rs => src/lib.rs +13 -10
@@ 35,7 35,7 @@ use nix::{
};
use std::{
    fs::{File, OpenOptions},
    io::{prelude::*, Error, ErrorKind, IoSlice, IoSliceMut, Result, SeekFrom},
    io::{prelude::*, Error, IoSlice, IoSliceMut, Result, SeekFrom},
    os::unix::{
        fs::FileExt,
        io::{AsRawFd, RawFd},


@@ 265,10 265,7 @@ impl Drop for FileLock {
}

fn cver(e: nix::Error) -> Error {
    match e.as_errno() {
        Some(e) => Error::from_raw_os_error(e as i32),
        None => Error::new(ErrorKind::Other, e),
    }
    Error::from_raw_os_error(e as i32)
}

#[cfg(test)]


@@ 311,8 308,11 @@ mod test {
                                    match *already_locked {
                                        false => None,
                                        true => {
                                            match FileLock::lock(&filename, true, *already_writable)
                                            {
                                            match FileLock::lock(
                                                &filename,
                                                true,
                                                *already_writable,
                                            ) {
                                                Ok(lock) => Some(lock),
                                                Err(err) => {
                                                    panic!("Error creating parent lock ({})", err)


@@ 323,7 323,7 @@ mod test {
                                }
                            };

                            match fork() {
                            match unsafe { fork() } {
                                Ok(Parent { child: _ }) => {
                                    sleep(Duration::from_millis(150));



@@ 361,7 361,8 @@ mod test {
                                                        }
                                                        Err(_) => {
                                                            sleep(Duration::from_millis(50));
                                                            try_count = try_count + 1;
                                                            try_count =
                                                                try_count + 1;
                                                        }
                                                    }
                                                }


@@ 373,7 374,9 @@ mod test {
                                            *is_writable,
                                        ) {
                                            Ok(_) => locked = true,
                                            Err(_) => match !*already_exists && !*is_writable {
                                            Err(_) => match !*already_exists
                                                && !*is_writable
                                            {
                                                true => {}
                                                false => {
                                                    panic!("Error getting lock with no competition")