Skip to content

Commit 4ae2012

Browse files
committed
dist: track progress during unpacking
1 parent bfc9a84 commit 4ae2012

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, info, warn};
1313
use url::Url;
@@ -390,6 +390,18 @@ impl DownloadStatus {
390390
);
391391
}
392392

393+
pub(crate) fn unpack<T: Read>(&self, inner: T) -> ProgressBarIter<T> {
394+
self.progress.reset();
395+
self.progress.set_style(
396+
ProgressStyle::with_template(
397+
"{msg:>12.bold} unpacking [{bar:20}] {bytes}/{total_bytes} ({bytes_per_sec}, ETA: {eta})",
398+
)
399+
.unwrap()
400+
.progress_chars("## ")
401+
);
402+
self.progress.wrap_read(inner)
403+
}
404+
393405
pub(crate) fn installing(&self) {
394406
self.progress.set_style(
395407
ProgressStyle::with_template(

src/dist/manifestation.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,14 +685,12 @@ impl<'a> ComponentBinary<'a> {
685685
let short_pkg_name = self.component.short_name_in_manifest();
686686
let short_name = self.manifest.short_name(&self.component);
687687

688-
self.status.installing();
689-
690-
let reader = utils::buffered(&installer_file)?;
691688
let temp_dir = self.download_cfg.tmp_cx.new_directory()?;
692689
let io_executor = get_executor(
693690
unpack_ram(IO_CHUNK_SIZE, self.download_cfg.process.unpack_ram()?),
694691
self.download_cfg.process.io_thread_count()?,
695692
);
693+
let reader = self.status.unpack(utils::buffered(&installer_file)?);
696694
let package =
697695
DirectoryPackage::compressed(reader, self.binary.compression, temp_dir, io_executor)?;
698696

@@ -702,6 +700,7 @@ impl<'a> ComponentBinary<'a> {
702700
return Err(RustupError::CorruptComponent(short_name.to_owned()).into());
703701
}
704702

703+
self.status.installing();
705704
let tx = package.install(
706705
&manifestation.installation,
707706
&pkg_name,

0 commit comments

Comments
 (0)