summaryrefslogtreecommitdiffstats
path: root/src/commands/source.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/source.rs')
-rw-r--r--src/commands/source.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/commands/source.rs b/src/commands/source.rs
index 5284678..8b1cf3e 100644
--- a/src/commands/source.rs
+++ b/src/commands/source.rs
@@ -271,10 +271,18 @@ pub async fn download(
bar.set_length(len);
}
let mut stream = reqwest::get(source.url().as_ref()).await?.bytes_stream();
+ let mut bytes_written = 0;
while let Some(bytes) = stream.next().await {
let bytes = bytes?;
file.write_all(bytes.as_ref()).await?;
+ bytes_written += bytes.len();
+
bar.inc(bytes.len() as u64);
+ if let Some(len) = response.content_length() {
+ bar.set_message(&format!("Downloading {} ({}/{} bytes)", source.url(), bytes_written, len));
+ } else {
+ bar.set_message(&format!("Downloading {} ({} bytes)", source.url(), bytes_written));
+ }
}
file.flush().await?;