src/api2/admin/datastore/backup/environment.rs: add more consistency checks
This commit is contained in:
parent
3dc5b2a203
commit
006f3ff407
@ -231,9 +231,18 @@ impl BackupEnvironment {
|
||||
};
|
||||
|
||||
if data.chunk_count != chunk_count {
|
||||
bail!("fixed writer '{}' close failed - unexpected chunk count ({} != {})", data.name, data.chunk_count, chunk_count);
|
||||
bail!("fixed writer '{}' close failed - received wrong number of chunk ({} != {})", data.name, data.chunk_count, chunk_count);
|
||||
}
|
||||
|
||||
let expected_count = data.index.index_length();
|
||||
|
||||
if chunk_count != (expected_count as u64) {
|
||||
bail!("fixed writer '{}' close failed - unexpected chunk count ({} != {})", data.name, expected_count, chunk_count);
|
||||
}
|
||||
|
||||
if size != (data.size as u64) {
|
||||
bail!("fixed writer '{}' close failed - unexpected file size ({} != {})", data.name, data.size, size);
|
||||
}
|
||||
|
||||
data.index.close()?;
|
||||
|
||||
|
@ -278,6 +278,10 @@ impl FixedIndexWriter {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn index_length(&self) -> usize {
|
||||
self.index_length
|
||||
}
|
||||
|
||||
fn unmap(&mut self) -> Result<(), Error> {
|
||||
|
||||
if self.index == std::ptr::null_mut() { return Ok(()); }
|
||||
@ -354,7 +358,6 @@ impl FixedIndexWriter {
|
||||
}
|
||||
|
||||
pub fn add_digest(&mut self, index: usize, digest: &[u8; 32]) -> Result<(), Error> {
|
||||
|
||||
if index >= self.index_length {
|
||||
bail!("add digest failed - index out of range ({} >= {})", index, self.index_length);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user