src/client/http_client.rs: compute file checksums
This commit is contained in:
parent
a17a0e7a9f
commit
c807d231eb
@ -658,6 +658,7 @@ fn create_backup(
|
|||||||
acc.push(json!({
|
acc.push(json!({
|
||||||
"filename": filename,
|
"filename": filename,
|
||||||
"size": stats.size,
|
"size": stats.size,
|
||||||
|
"csum": proxmox::tools::digest_to_hex(&stats.csum),
|
||||||
}));
|
}));
|
||||||
acc
|
acc
|
||||||
});
|
});
|
||||||
|
@ -564,6 +564,7 @@ impl Drop for BackupClient {
|
|||||||
|
|
||||||
pub struct BackupStats {
|
pub struct BackupStats {
|
||||||
pub size: u64,
|
pub size: u64,
|
||||||
|
pub csum: [u8; 32],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BackupClient {
|
impl BackupClient {
|
||||||
@ -625,10 +626,11 @@ impl BackupClient {
|
|||||||
Ok(raw_data)
|
Ok(raw_data)
|
||||||
})
|
})
|
||||||
.and_then(move |raw_data| {
|
.and_then(move |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 });
|
||||||
h2.upload("blob", Some(param), raw_data)
|
h2.upload("blob", Some(param), raw_data)
|
||||||
.map(move |_| {
|
.map(move |_| {
|
||||||
BackupStats { size: size }
|
BackupStats { size, csum }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -661,10 +663,11 @@ impl BackupClient {
|
|||||||
Ok((raw_data, contents.len()))
|
Ok((raw_data, contents.len()))
|
||||||
})
|
})
|
||||||
.and_then(move |(raw_data, size)| {
|
.and_then(move |(raw_data, size)| {
|
||||||
|
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 });
|
||||||
h2.upload("blob", Some(param), raw_data)
|
h2.upload("blob", Some(param), raw_data)
|
||||||
.map(move |_| {
|
.map(move |_| {
|
||||||
BackupStats { size: size as u64 }
|
BackupStats { size: size as u64, csum }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@ -713,7 +716,7 @@ impl BackupClient {
|
|||||||
});
|
});
|
||||||
h2_4.post(&close_path, Some(param))
|
h2_4.post(&close_path, Some(param))
|
||||||
.map(move |_| {
|
.map(move |_| {
|
||||||
BackupStats { size: size as u64 }
|
BackupStats { size: size as u64, csum: [0u8; 32] }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user