backup/dynamic_index: split out add_chunk

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-02-25 13:50:45 +01:00
parent 9ac6ec868a
commit f661f37427

View File

@ -461,8 +461,7 @@ impl DynamicIndexWriter {
println!("ADD CHUNK {:016x} {} {}% {} {}", self.chunk_offset, chunk_size,
(compressed_size*100)/(chunk_size as u64), is_duplicate, tools::digest_to_hex(&digest));
self.writer.write(unsafe { &std::mem::transmute::<u64, [u8;8]>(self.chunk_offset as u64) })?;
self.writer.write(&digest)?;
self.add_chunk(self.chunk_offset as u64, &digest)?;
self.chunk_buffer.truncate(0);
return Ok(());
}
@ -472,6 +471,12 @@ impl DynamicIndexWriter {
}
}
}
pub fn add_chunk(&mut self, offset: u64, digest: &[u8; 32]) -> Result<(), std::io::Error> {
self.writer.write(unsafe { &std::mem::transmute::<u64, [u8;8]>(offset.to_le()) })?;
self.writer.write(digest)?;
Ok(())
}
}
impl Write for DynamicIndexWriter {