expose md5 in download output

This commit is contained in:
Robin Appelman 2024-01-26 21:41:53 +01:00
commit 70b2874d3b
4 changed files with 13 additions and 2 deletions

7
Cargo.lock generated
View file

@ -338,6 +338,12 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "hex_fmt"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f"
[[package]]
name = "itoa"
version = "1.0.10"
@ -711,6 +717,7 @@ dependencies = [
"clap",
"dashmap",
"hex",
"hex_fmt",
"md-5",
"rumqttc",
"serde",

View file

@ -20,4 +20,5 @@ hex = "0.4.3"
md-5 = "0.10.6"
[dev-dependencies]
clap = { version = "4.4.18", features = ["derive"] }
clap = { version = "4.4.18", features = ["derive"] }
hex_fmt = "0.3.0"

View file

@ -1,4 +1,5 @@
use clap::Parser;
use hex_fmt::HexFmt;
pub use tasmota_mqtt_client::{Result, TasmotaClient};
#[derive(Debug, Parser)]
@ -23,7 +24,7 @@ async fn main() -> Result<()> {
.download_config(&args.device, &args.device_password)
.await?;
println!("downloaded {}", file.name);
println!("downloaded {} with hash {}", file.name, HexFmt(file.md5));
if let Err(e) = std::fs::write(&file.name, file.data) {
eprintln!("Error while saving {}: {:#}", file.name, e);
}

View file

@ -27,6 +27,7 @@ struct DownloadState {
pub struct DownloadedFile {
pub name: String,
pub data: Bytes,
pub md5: [u8; 16],
}
#[derive(Deserialize, Debug)]
@ -131,5 +132,6 @@ pub async fn download_config(
Ok(DownloadedFile {
name: state.name,
data: state.data.freeze(),
md5: state.md5,
})
}