Skip to content

Commit

Permalink
Add progress bar to configure downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
oeb25 committed Nov 3, 2024
1 parent cae6339 commit 2d818dc
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions crates/core/src/entrypoint/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,21 @@ fn download_files() {
.await
.unwrap();

let progress = body.content_length().map(indicatif::ProgressBar::new);

let mut file = File::create(path).await.unwrap();
let mut bytes = body.bytes_stream();

while let Some(item) = bytes.next().await {
io::copy(&mut item.unwrap().as_ref(), &mut file)
.await
.unwrap();
let bytes = item.unwrap();
if let Some(progress) = &progress {
progress.inc(bytes.len() as _);
}
io::copy(&mut bytes.as_ref(), &mut file).await.unwrap();
}

if let Some(progress) = progress {
progress.finish_and_clear();
}
}
});
Expand Down

0 comments on commit 2d818dc

Please sign in to comment.