Skip to content

Commit 9606bd7

Browse files
committed
dist: track progress during unpacking
1 parent 92a688f commit 9606bd7

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/dist/download.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::sync::Mutex;
77
use std::time::{Duration, Instant};
88

99
use anyhow::{Context, Result, anyhow};
10-
use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle};
10+
use indicatif::{MultiProgress, ProgressBar, ProgressBarIter, ProgressDrawTarget, ProgressStyle};
1111
use sha2::{Digest, Sha256};
1212
use tracing::{debug, warn};
1313
use url::Url;
@@ -301,6 +301,18 @@ impl DownloadStatus {
301301
);
302302
}
303303

304+
pub(crate) fn unpack<T: Read>(&self, inner: T) -> ProgressBarIter<T> {
305+
self.progress.reset();
306+
self.progress.set_style(
307+
ProgressStyle::with_template(
308+
"{msg:>12.bold} unpacking {spinner:.green} {total_bytes:>18}",
309+
)
310+
.unwrap()
311+
.tick_chars(r"|/-\ "),
312+
);
313+
self.progress.wrap_read(inner)
314+
}
315+
304316
pub(crate) fn installing(&self) {
305317
self.progress.set_style(
306318
ProgressStyle::with_template(

src/dist/manifestation.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,7 @@ impl<'a> ComponentBinary<'a> {
720720
let short_pkg_name = component.short_name_in_manifest();
721721
let short_name = component.short_name(self.manifest);
722722

723-
self.status.installing();
724-
725-
let reader = utils::buffered(&installer_file)?;
723+
let reader = self.status.unpack(utils::buffered(&installer_file)?);
726724
let package =
727725
DirectoryPackage::compressed(reader, self.binary.compression, self.download_cfg)?;
728726

@@ -732,6 +730,7 @@ impl<'a> ComponentBinary<'a> {
732730
return Err(RustupError::CorruptComponent(short_name).into());
733731
}
734732

733+
self.status.installing();
735734
let tx = package.install(
736735
&manifestation.installation,
737736
&pkg_name,

0 commit comments

Comments
 (0)