proxmox-rrd: cleanup list_old_journals

This commit is contained in:
Dietmar Maurer 2021-10-18 10:00:16 +02:00
parent 2b05008a11
commit d26865c52c
1 changed files with 18 additions and 14 deletions

View File

@ -122,20 +122,24 @@ impl JournalState {
for entry in std::fs::read_dir(&self.config.basedir)? { for entry in std::fs::read_dir(&self.config.basedir)? {
let entry = entry?; let entry = entry?;
let path = entry.path(); let path = entry.path();
if path.is_file() {
if let Some(stem) = path.file_stem() { if !path.is_file() { continue; }
if stem != OsStr::new("rrd") { continue; }
if let Some(extension) = path.extension() { match path.file_stem() {
if let Some(extension) = extension.to_str() { None => continue,
if let Some(rest) = extension.strip_prefix("journal-") { Some(stem) if stem != OsStr::new("rrd") => continue,
if let Ok(time) = u64::from_str_radix(rest, 16) { Some(_) => (),
list.push(JournalFileInfo { }
time,
name: format!("rrd.{}", extension), if let Some(extension) = path.extension() {
path: path.to_owned(), 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(),
});
} }
} }
} }