mirror of
https://codeberg.org/icewind/tasmota-backup.git
synced 2026-06-03 22:34:10 +02:00
add option to backup a single device
This commit is contained in:
parent
087bb085b3
commit
0e7839f2b9
1 changed files with 13 additions and 10 deletions
23
src/main.rs
23
src/main.rs
|
|
@ -16,6 +16,7 @@ mod config;
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
struct Args {
|
struct Args {
|
||||||
config: PathBuf,
|
config: PathBuf,
|
||||||
|
device: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|
@ -35,16 +36,18 @@ async fn main() -> Result<()> {
|
||||||
let devices = client.current_devices();
|
let devices = client.current_devices();
|
||||||
info!("found {} devices", devices.len());
|
info!("found {} devices", devices.len());
|
||||||
for device in devices {
|
for device in devices {
|
||||||
let result = timeout(
|
if args.device.is_none() || args.device.as_deref() == Some(device.as_str()) {
|
||||||
Duration::from_secs(120),
|
let result = timeout(
|
||||||
download(&client, &device, &config.output.target, &device_password),
|
Duration::from_secs(120),
|
||||||
)
|
download(&client, &device, &config.output.target, &device_password),
|
||||||
.await;
|
)
|
||||||
let result = result
|
.await;
|
||||||
.with_context(|| format!("Timeout while downloading config for {device}"))
|
let result = result
|
||||||
.and_then(|res| res);
|
.with_context(|| format!("Timeout while downloading config for {device}"))
|
||||||
if let Err(e) = result {
|
.and_then(|res| res);
|
||||||
error!(device = device, error = %e, "Failed to download config for {device}");
|
if let Err(e) = result {
|
||||||
|
error!(device = device, error = %e, "Failed to download config for {device}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue