Исправлены clippy-замечания под gate -D warnings
This commit is contained in:
@@ -11,6 +11,7 @@ pub struct FileLock {
|
||||
}
|
||||
|
||||
impl FileLock {
|
||||
#[cfg(test)]
|
||||
pub fn acquire(path: &str) -> anyhow::Result<Self> {
|
||||
Self::acquire_timeout(path, Duration::from_secs(0))
|
||||
}
|
||||
@@ -42,9 +43,9 @@ impl FileLock {
|
||||
match OpenOptions::new().create_new(true).write(true).open(p) {
|
||||
Ok(mut file) => {
|
||||
file.write_all(std::process::id().to_string().as_bytes())?;
|
||||
return Ok(Self {
|
||||
Ok(Self {
|
||||
path: path.to_string(),
|
||||
});
|
||||
})
|
||||
}
|
||||
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => {
|
||||
let stale = is_stale_lock(p)?;
|
||||
@@ -52,13 +53,14 @@ impl FileLock {
|
||||
let _ = fs::remove_file(p);
|
||||
let mut file = OpenOptions::new().create_new(true).write(true).open(p)?;
|
||||
file.write_all(std::process::id().to_string().as_bytes())?;
|
||||
return Ok(Self {
|
||||
Ok(Self {
|
||||
path: path.to_string(),
|
||||
});
|
||||
})
|
||||
} else {
|
||||
anyhow::bail!("lock already exists: {path}");
|
||||
}
|
||||
anyhow::bail!("lock already exists: {path}");
|
||||
}
|
||||
Err(e) => return Err(e.into()),
|
||||
Err(e) => Err(e.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user