src/rrd/cache.rs: display/log error when RRD load fails

This commit is contained in:
Dietmar Maurer
2020-05-25 10:18:53 +02:00
parent 0c4344650d
commit 84dc6adcc1
2 changed files with 20 additions and 8 deletions

View File

@ -56,7 +56,12 @@ pub fn update_value(rel_path: &str, value: f64, dst: DST) -> Result<(), Error> {
} else {
let mut rrd = match RRD::load(&path) {
Ok(rrd) => rrd,
Err(_) => RRD::new(dst),
Err(err) => {
if err.kind() != std::io::ErrorKind::NotFound {
eprintln!("overwriting old RRD file, because of load error: {}", err);
}
RRD::new(dst)
},
};
rrd.update(now, value);
rrd.save(&path)?;