src/client/http_client.rs: store raw data/blob size in index.json
This commit is contained in:
parent
f16aea687a
commit
ff01c1e393
@ -913,7 +913,7 @@ fn verify_index_file(backup_index: &Value, name: &str, csum: &[u8; 32], size: u6
|
|||||||
None => bail!("index does not contain property 'size' for file '{}'", name),
|
None => bail!("index does not contain property 'size' for file '{}'", name),
|
||||||
Some(expected_size) => {
|
Some(expected_size) => {
|
||||||
if expected_size != size {
|
if expected_size != size {
|
||||||
bail!("verify index failed - wrong size for file '{}'", name);
|
bail!("verify index failed - wrong size for file '{}' ({} != {}", name, expected_size, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -660,7 +660,7 @@ impl BackupClient {
|
|||||||
|
|
||||||
let csum = openssl::sha::sha256(&raw_data);
|
let csum = openssl::sha::sha256(&raw_data);
|
||||||
let param = json!({"encoded-size": raw_data.len(), "file-name": file_name });
|
let param = json!({"encoded-size": raw_data.len(), "file-name": file_name });
|
||||||
let size = raw_data.len() as u64; // fixme: should be decoded size instead??
|
let size = raw_data.len() as u64;
|
||||||
let _value = self.h2.upload("POST", "blob", Some(param), "application/octet-stream", raw_data).await?;
|
let _value = self.h2.upload("POST", "blob", Some(param), "application/octet-stream", raw_data).await?;
|
||||||
Ok(BackupStats { size, csum })
|
Ok(BackupStats { size, csum })
|
||||||
}
|
}
|
||||||
@ -674,8 +674,6 @@ impl BackupClient {
|
|||||||
sign_only: bool,
|
sign_only: bool,
|
||||||
) -> Result<BackupStats, Error> {
|
) -> Result<BackupStats, Error> {
|
||||||
|
|
||||||
let size = data.len() as u64;
|
|
||||||
|
|
||||||
let blob = if let Some(crypt_config) = crypt_config {
|
let blob = if let Some(crypt_config) = crypt_config {
|
||||||
if sign_only {
|
if sign_only {
|
||||||
DataBlob::create_signed(&data, crypt_config, compress)?
|
DataBlob::create_signed(&data, crypt_config, compress)?
|
||||||
@ -687,9 +685,10 @@ impl BackupClient {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let raw_data = blob.into_inner();
|
let raw_data = blob.into_inner();
|
||||||
|
let size = raw_data.len() as u64;
|
||||||
|
|
||||||
let csum = openssl::sha::sha256(&raw_data);
|
let csum = openssl::sha::sha256(&raw_data);
|
||||||
let param = json!({"encoded-size": raw_data.len(), "file-name": file_name });
|
let param = json!({"encoded-size": size, "file-name": file_name });
|
||||||
let _value = self.h2.upload("POST", "blob", Some(param), "application/octet-stream", raw_data).await?;
|
let _value = self.h2.upload("POST", "blob", Some(param), "application/octet-stream", raw_data).await?;
|
||||||
Ok(BackupStats { size, csum })
|
Ok(BackupStats { size, csum })
|
||||||
}
|
}
|
||||||
@ -714,12 +713,12 @@ impl BackupClient {
|
|||||||
.await
|
.await
|
||||||
.map_err(|err| format_err!("unable to read file {:?} - {}", src_path, err))?;
|
.map_err(|err| format_err!("unable to read file {:?} - {}", src_path, err))?;
|
||||||
|
|
||||||
let size: u64 = contents.len() as u64;
|
|
||||||
let blob = DataBlob::encode(&contents, crypt_config, compress)?;
|
let blob = DataBlob::encode(&contents, crypt_config, compress)?;
|
||||||
let raw_data = blob.into_inner();
|
let raw_data = blob.into_inner();
|
||||||
|
let size = raw_data.len() as u64;
|
||||||
let csum = openssl::sha::sha256(&raw_data);
|
let csum = openssl::sha::sha256(&raw_data);
|
||||||
let param = json!({
|
let param = json!({
|
||||||
"encoded-size": raw_data.len(),
|
"encoded-size": size,
|
||||||
"file-name": file_name,
|
"file-name": file_name,
|
||||||
});
|
});
|
||||||
self.h2.upload("POST", "blob", Some(param), "application/octet-stream", raw_data).await?;
|
self.h2.upload("POST", "blob", Some(param), "application/octet-stream", raw_data).await?;
|
||||||
|
Loading…
Reference in New Issue
Block a user