proxmox-rrd: cleanup - use struct instead of tuple
This commit is contained in:
parent
45700e2ecf
commit
2b05008a11
@ -318,14 +318,14 @@ fn apply_journal_impl(
|
|||||||
// Apply old journals first
|
// Apply old journals first
|
||||||
let journal_list = state.read().unwrap().list_old_journals()?;
|
let journal_list = state.read().unwrap().list_old_journals()?;
|
||||||
|
|
||||||
for (_time, filename, path) in journal_list {
|
for entry in journal_list {
|
||||||
log::info!("apply old journal log {}", filename);
|
log::info!("apply old journal log {}", entry.name);
|
||||||
let file = std::fs::OpenOptions::new().read(true).open(path)?;
|
let file = std::fs::OpenOptions::new().read(true).open(&entry.path)?;
|
||||||
let mut reader = BufReader::new(file);
|
let mut reader = BufReader::new(file);
|
||||||
lines += apply_journal_lines(
|
lines += apply_journal_lines(
|
||||||
Arc::clone(&state),
|
Arc::clone(&state),
|
||||||
Arc::clone(&rrd_map),
|
Arc::clone(&rrd_map),
|
||||||
&filename,
|
&entry.name,
|
||||||
&mut reader,
|
&mut reader,
|
||||||
false,
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
20
proxmox-rrd/src/cache/journal.rs
vendored
20
proxmox-rrd/src/cache/journal.rs
vendored
@ -31,6 +31,12 @@ pub struct JournalEntry {
|
|||||||
pub rel_path: String,
|
pub rel_path: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct JournalFileInfo {
|
||||||
|
pub time: u64,
|
||||||
|
pub name: String,
|
||||||
|
pub path: PathBuf,
|
||||||
|
}
|
||||||
|
|
||||||
impl JournalState {
|
impl JournalState {
|
||||||
|
|
||||||
pub(crate) fn new(config: Arc<CacheConfig>) -> Result<Self, Error> {
|
pub(crate) fn new(config: Arc<CacheConfig>) -> Result<Self, Error> {
|
||||||
@ -104,14 +110,14 @@ impl JournalState {
|
|||||||
|
|
||||||
let journal_list = self.list_old_journals()?;
|
let journal_list = self.list_old_journals()?;
|
||||||
|
|
||||||
for (_time, _filename, path) in journal_list {
|
for entry in journal_list {
|
||||||
std::fs::remove_file(path)?;
|
std::fs::remove_file(entry.path)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_old_journals(&self) -> Result<Vec<(u64, String, PathBuf)>, Error> {
|
pub fn list_old_journals(&self) -> Result<Vec<JournalFileInfo>, Error> {
|
||||||
let mut list = Vec::new();
|
let mut list = Vec::new();
|
||||||
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?;
|
||||||
@ -123,7 +129,11 @@ impl JournalState {
|
|||||||
if let Some(extension) = extension.to_str() {
|
if let Some(extension) = extension.to_str() {
|
||||||
if let Some(rest) = extension.strip_prefix("journal-") {
|
if let Some(rest) = extension.strip_prefix("journal-") {
|
||||||
if let Ok(time) = u64::from_str_radix(rest, 16) {
|
if let Ok(time) = u64::from_str_radix(rest, 16) {
|
||||||
list.push((time, format!("rrd.{}", extension), path.to_owned()));
|
list.push(JournalFileInfo {
|
||||||
|
time,
|
||||||
|
name: format!("rrd.{}", extension),
|
||||||
|
path: path.to_owned(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,7 +141,7 @@ impl JournalState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.sort_unstable_by_key(|t| t.0);
|
list.sort_unstable_by_key(|entry| entry.time);
|
||||||
Ok(list)
|
Ok(list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user