Skip to content

Commit 94e0361

Browse files
committed
Print uploaded filename and checksum
This will help to research deduplication efforts. Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
1 parent f3be6ea commit 94e0361

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ hex = "0.4.3"
2020
hmac = "0.12.1"
2121
http-body-util = "0.1.2"
2222
jwt = "0.16.0"
23-
openssl = { version = "0.10.68", features = ["vendored"] }
2423
rand = "0.8.5"
2524
reqwest = { version = "0.12.9", features = ["blocking"] }
2625
rustls = "0.23.20"

src/azure.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ fn get_azure_credentials(name: &str) -> AzureConfig {
5555
};
5656
}
5757

58+
fn calculate_checksum(filename: &String, data: &[u8]) {
59+
let hash = sha2_512::default().update(data).finalize();
60+
let digest = hash.digest();
61+
println!("File: {} Checksum: {}", filename, digest.to_hex_lowercase());
62+
63+
}
64+
5865
/// Write file to Azure blob storage
5966
/// TBD: Rework, do not keep whole file as Vec<u8> in memory!!!
6067
async fn write_file_to_blob(filename: String, data: Vec<u8>, cont_type: String) -> &'static str {
@@ -83,6 +90,8 @@ async fn write_file_to_blob(filename: String, data: Vec<u8>, cont_type: String)
8390
let mut total_bytes_uploaded: usize = 0;
8491
let chunk_size = 10;
8592
let mut blocks = BlockList::default();
93+
94+
calculate_checksum(&filename, &data);
8695
loop {
8796
let mut buffer = vec![0; chunk_size * 1024 * 1024];
8897
let bytes_read = f.read(&mut buffer);

0 commit comments

Comments
 (0)