Skip to content

Commit 0c28829

Browse files
committed
join all
1 parent ab90fdd commit 0c28829

File tree

3 files changed

+114
-6
lines changed

3 files changed

+114
-6
lines changed

Cargo.lock

+105
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ anyhow = "1.0.83"
1010
clap = { version = "4.5.4", features = ["derive"] }
1111
dirs-next = "2.0.0"
1212
indicatif = "0.17.8"
13+
futures = "0.3.30"

src/scp.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use futures::future::join_all;
12
use indicatif::ProgressBar;
23
use ssh2::Session;
34
use std::{
@@ -40,13 +41,14 @@ impl Connect {
4041
handles.push(handle);
4142
}
4243

43-
for handle in handles {
44-
handle.await??;
45-
}
46-
47-
println!("Done in {:.2?}", start.elapsed());
44+
let items = join_all(handles).await;
4845

49-
Ok(())
46+
if items.iter().all(|x| x.is_ok()) {
47+
println!("Done in {:.2?}", start.elapsed());
48+
Ok(())
49+
} else {
50+
Err(anyhow::anyhow!("One or more files failed to copy"))
51+
}
5052
}
5153

5254
fn list(&self, dir: &PathBuf) -> anyhow::Result<Vec<PathBuf>> {

0 commit comments

Comments
 (0)