Main: Write failed integrity checks to "restic-integrity-log"
This commit is contained in:
parent
0f7b8cf4e5
commit
2e3c1b6a97
1 changed files with 18 additions and 2 deletions
|
@ -1,14 +1,16 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2022, networkException <git@nwex.de>
|
* Copyright (c) 2024, networkException <git@nwex.de>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use chrono::Local;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use indicatif::{ParallelProgressIterator, ProgressBar, ProgressStyle, ProgressFinish};
|
use indicatif::{ParallelProgressIterator, ProgressBar, ProgressStyle, ProgressFinish};
|
||||||
use rayon::ThreadPoolBuilder;
|
use rayon::ThreadPoolBuilder;
|
||||||
use rayon::iter::{ParallelIterator, IntoParallelRefIterator};
|
use rayon::iter::{ParallelIterator, IntoParallelRefIterator};
|
||||||
use std::fs::File;
|
use std::fs::{File, OpenOptions};
|
||||||
|
use std::io::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::io::{self, Result, Error, ErrorKind};
|
use std::io::{self, Result, Error, ErrorKind};
|
||||||
use sha2::{Sha256, Digest};
|
use sha2::{Sha256, Digest};
|
||||||
|
@ -100,6 +102,20 @@ fn run() -> Result<()> {
|
||||||
let path_string = path.to_str().unwrap();
|
let path_string = path.to_str().unwrap();
|
||||||
|
|
||||||
eprintln!("Integrity check failed for {}: Expected {}, got {}", path_string, filename, hash);
|
eprintln!("Integrity check failed for {}: Expected {}, got {}", path_string, filename, hash);
|
||||||
|
|
||||||
|
let file = OpenOptions::new()
|
||||||
|
.create(true)
|
||||||
|
.append(true)
|
||||||
|
.open("restic-integrity-log");
|
||||||
|
|
||||||
|
match file {
|
||||||
|
Err(error) => eprintln!("Unable to write to restic-integrity-log: {}", error),
|
||||||
|
Ok(mut file) => {
|
||||||
|
if let Err(error) = writeln!(file, "{}: Integrity check failed for {}: Expected {}, got {}", Local::now().format("%Y-%m-%d %H:%M:%S"), path_string, filename, hash) {
|
||||||
|
eprintln!("Unable to write to restic-integrity-log: {}", error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue