summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Hummer <paul@eventuallyanyway.com>2018-06-05 09:55:20 -0600
committerPaul Hummer <paul@eventuallyanyway.com>2018-06-05 09:55:20 -0600
commit2f418cff774a293457df66c0f67dc930c3abfc9c (patch)
tree5e20de127b65292006c3ab38e20d4ab8febf0178 /src
parent3cff7fcbbd419dfe1d4c15140e8e02d016926359 (diff)
Fix small lintHEADmaster
♬ : Joshua Radin / No Envy No Fear (Live)
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs25
1 files 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::<i32>() {
- 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::<i32>() {
+ 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 {