summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-12-02 14:10:19 +0100
committerMatthias Beyer <matthias.beyer@atos.net>2021-12-02 14:23:51 +0100
commit17351984e3935f3273a03ecff24776a5acd381e4 (patch)
treeb051c5602be39196e2f01efae7e07a2aced086d6
parent781fae3dba04b3e0e97db0a7f28f5d132d356754 (diff)
Optimize: Write bytes to disk and increase statusbar in parallel
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
-rw-r--r--src/commands/source/download.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/commands/source/download.rs b/src/commands/source/download.rs
index 67a0cad..b73a074 100644
--- a/src/commands/source/download.rs
+++ b/src/commands/source/download.rs
@@ -140,11 +140,16 @@ async fn perform_download(source: &SourceEntry, progress: Arc<Mutex<ProgressWrap
let mut stream = response.bytes_stream();
while let Some(bytes) = stream.next().await {
let bytes = bytes?;
- file.write_all(bytes.as_ref()).await?;
- progress.lock()
- .await
- .add_bytes(bytes.len())
- .await
+ tokio::try_join!(
+ file.write_all(bytes.as_ref()),
+ async {
+ progress.lock()
+ .await
+ .add_bytes(bytes.len())
+ .await;
+ Ok(())
+ }
+ )?;
}
file.flush()