remove DataChunk file format - use DataBlob instead
This commit is contained in:
@ -678,7 +678,7 @@ impl BackupClient {
|
||||
if sign_only {
|
||||
DataBlob::create_signed(&data, crypt_config, compress)?
|
||||
} else {
|
||||
DataBlob::encode(&data, Some(crypt_config.clone()), compress)?
|
||||
DataBlob::encode(&data, Some(crypt_config), compress)?
|
||||
}
|
||||
} else {
|
||||
DataBlob::encode(&data, None, compress)?
|
||||
@ -936,7 +936,7 @@ impl BackupClient {
|
||||
.compress(true);
|
||||
|
||||
if let Some(ref crypt_config) = crypt_config {
|
||||
chunk_builder = chunk_builder.crypt_config(crypt_config);
|
||||
chunk_builder = chunk_builder.crypt_config(crypt_config.clone());
|
||||
}
|
||||
|
||||
let mut known_chunks = known_chunks.lock().unwrap();
|
||||
@ -957,8 +957,9 @@ impl BackupClient {
|
||||
known_chunks.insert(*digest);
|
||||
future::ready(chunk_builder
|
||||
.build()
|
||||
.map(move |chunk| MergedChunkInfo::New(ChunkInfo {
|
||||
.map(move |(chunk, digest)| MergedChunkInfo::New(ChunkInfo {
|
||||
chunk,
|
||||
digest,
|
||||
chunk_len: chunk_len as u64,
|
||||
offset,
|
||||
}))
|
||||
@ -970,7 +971,7 @@ impl BackupClient {
|
||||
|
||||
if let MergedChunkInfo::New(chunk_info) = merged_chunk_info {
|
||||
let offset = chunk_info.offset;
|
||||
let digest = *chunk_info.chunk.digest();
|
||||
let digest = chunk_info.digest;
|
||||
let digest_str = digest_to_hex(&digest);
|
||||
|
||||
println!("upload new chunk {} ({} bytes, offset {})", digest_str,
|
||||
|
@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||
use failure::*;
|
||||
|
||||
use super::BackupReader;
|
||||
use crate::backup::{ReadChunk, DataChunk, CryptConfig};
|
||||
use crate::backup::{ReadChunk, DataBlob, CryptConfig};
|
||||
|
||||
/// Read chunks from remote host using ``BackupReader``
|
||||
pub struct RemoteChunkReader {
|
||||
@ -43,13 +43,12 @@ impl ReadChunk for RemoteChunkReader {
|
||||
|
||||
futures::executor::block_on(self.client.download_chunk(&digest, &mut chunk_data))?;
|
||||
|
||||
let chunk = DataChunk::from_raw(chunk_data, *digest)?;
|
||||
let chunk = DataBlob::from_raw(chunk_data)?;
|
||||
chunk.verify_crc()?;
|
||||
|
||||
let raw_data = match self.crypt_config {
|
||||
Some(ref crypt_config) => chunk.decode(Some(crypt_config))?,
|
||||
None => chunk.decode(None)?,
|
||||
};
|
||||
let raw_data = chunk.decode(self.crypt_config.clone())?;
|
||||
|
||||
// fixme: verify chunk digest
|
||||
|
||||
if use_cache {
|
||||
self.cache.insert(*digest, raw_data.to_vec());
|
||||
|
Reference in New Issue
Block a user