src/backup/index.rs: add compute_csum

And use it for fixed and dynamic index. Please note that this
changes checksums for fixed indexes, so restore older backups
will fails now (not backward compatible).
This commit is contained in:
Dietmar Maurer
2020-06-26 09:00:34 +02:00
parent 19b5c3c43e
commit 1f82f9b7b5
3 changed files with 15 additions and 42 deletions

View File

@ -141,24 +141,6 @@ impl DynamicIndexReader {
&self.index[pos].digest
}
/// Compute checksum and data size
pub fn compute_csum(&self) -> ([u8; 32], u64) {
let mut csum = openssl::sha::Sha256::new();
for entry in &self.index {
csum.update(&entry.end_le.to_ne_bytes());
csum.update(&entry.digest);
}
let csum = csum.finish();
(
csum,
self.index
.last()
.map(|entry| entry.end())
.unwrap_or(0)
)
}
// TODO: can we use std::slice::binary_search with Mmap now?
fn binary_search(
&self,