summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-12-02 13:09:10 +0100
committerMatthias Beyer <matthias.beyer@atos.net>2021-12-02 14:23:48 +0100
commit1438fc5ee803cf78ed29bf0e030b3cf1fd72f33e (patch)
tree820b958e786f35b2e1d4f1ed78ad9a2f0543c0be /src
parentbadd1a6968367dfc60ee2d38ddf20b0b530be10d (diff)
Fix: Use already existing response type to get byte stream, instead of starting new GET request
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src')
-rw-r--r--src/commands/source.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/commands/source.rs b/src/commands/source.rs
index 68a8926..2709df8 100644
--- a/src/commands/source.rs
+++ b/src/commands/source.rs
@@ -261,7 +261,8 @@ pub async fn download(
bar.set_length(len);
}
- let mut stream = reqwest::get(source.url().as_ref()).await?.bytes_stream();
+ let content_length = response.content_length();
+ let mut stream = response.bytes_stream();
let mut bytes_written = 0;
while let Some(bytes) = stream.next().await {
let bytes = bytes?;
@@ -269,7 +270,7 @@ pub async fn download(
bytes_written += bytes.len();
bar.inc(bytes.len() as u64);
- if let Some(len) = response.content_length() {
+ if let Some(len) = content_length {
bar.set_message(format!("Downloading {} ({}/{} bytes)", source.url(), bytes_written, len));
} else {
bar.set_message(format!("Downloading {} ({} bytes)", source.url(), bytes_written));