From e23f3ec77477b309e5169629bde20bd95a1fb9ee Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 18 Oct 2021 10:00:16 +0200 Subject: [PATCH] proxmox-rrd: cleanup list_old_journals --- proxmox-rrd/src/cache/journal.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/proxmox-rrd/src/cache/journal.rs b/proxmox-rrd/src/cache/journal.rs index cd84cc7f..592e18ec 100644 --- a/proxmox-rrd/src/cache/journal.rs +++ b/proxmox-rrd/src/cache/journal.rs @@ -122,20 +122,24 @@ impl JournalState { for entry in std::fs::read_dir(&self.config.basedir)? { let entry = entry?; let path = entry.path(); - if path.is_file() { - if let Some(stem) = path.file_stem() { - if stem != OsStr::new("rrd") { continue; } - if let Some(extension) = path.extension() { - if let Some(extension) = extension.to_str() { - if let Some(rest) = extension.strip_prefix("journal-") { - if let Ok(time) = u64::from_str_radix(rest, 16) { - list.push(JournalFileInfo { - time, - name: format!("rrd.{}", extension), - path: path.to_owned(), - }); - } - } + + if !path.is_file() { continue; } + + match path.file_stem() { + None => continue, + Some(stem) if stem != OsStr::new("rrd") => continue, + Some(_) => (), + } + + if let Some(extension) = path.extension() { + if let Some(extension) = extension.to_str() { + if let Some(rest) = extension.strip_prefix("journal-") { + if let Ok(time) = u64::from_str_radix(rest, 16) { + list.push(JournalFileInfo { + time, + name: format!("rrd.{}", extension), + path: path.to_owned(), + }); } } }