From 2f418cff774a293457df66c0f67dc930c3abfc9c Mon Sep 17 00:00:00 2001 From: Paul Hummer Date: Tue, 5 Jun 2018 09:55:20 -0600 Subject: Fix small lint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ♬ : Joshua Radin / No Envy No Fear (Live) --- src/lib.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b9138b0..b1e40c7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,23 +50,20 @@ impl Pidlock { } fn check_stale(&self) { - match fs::OpenOptions::new().read(true).open(self.path.clone()) { - Ok(mut file) => { - let mut contents = String::new(); - file.read_to_string(&mut contents).unwrap(); - - match contents.trim().parse::() { - Ok(pid) => { - if !process_exists(pid) { - warn!("Removing stale pid file at {}", self.path); - fs::remove_file(&self.path).unwrap(); - } + if let Ok(mut file) = fs::OpenOptions::new().read(true).open(self.path.clone()) { + let mut contents = String::new(); + file.read_to_string(&mut contents).unwrap(); + + match contents.trim().parse::() { + Ok(pid) => { + if !process_exists(pid) { + warn!("Removing stale pid file at {}", self.path); + fs::remove_file(&self.path).unwrap(); } - Err(_) => fs::remove_file(&self.path).unwrap(), } + Err(_) => fs::remove_file(&self.path).unwrap(), } - Err(_) => {} - }; + } } pub fn acquire(&mut self) -> PidlockResult { -- cgit v1.2.3