Исправлены clippy-замечания под gate -D warnings

This commit is contained in:
2026-05-12 12:19:47 +05:00
parent d114784d7d
commit bff9c50a6b
6 changed files with 43 additions and 39 deletions
+8 -6
View File
@@ -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()),
}
}
}