From d73d11bcefabdded416cfa1a71c05fa847622b1b Mon Sep 17 00:00:00 2001 From: Francisco Gouveia Date: Tue, 21 Oct 2025 10:44:41 +0100 Subject: [PATCH 1/2] installations: handle installation of components through progress bars --- src/dist/download.rs | 27 +++++++++++++++++++++++---- src/dist/manifestation.rs | 18 +++++------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/dist/download.rs b/src/dist/download.rs index dabf990311..ff998108dc 100644 --- a/src/dist/download.rs +++ b/src/dist/download.rs @@ -269,10 +269,10 @@ impl DownloadStatus { pub(crate) fn finished(&self) { self.progress.set_style( - ProgressStyle::with_template("{msg:>12.bold} downloaded {total_bytes} in {elapsed}") + ProgressStyle::with_template("{msg:>12.bold} pending installation") .unwrap(), ); - self.progress.finish(); + self.progress.tick(); // A tick is needed for the new style to appear, as it is static. } pub(crate) fn failed(&self) { @@ -285,8 +285,27 @@ impl DownloadStatus { pub(crate) fn retrying(&self) { *self.retry_time.lock().unwrap() = Some(Instant::now()); - self.progress - .set_style(ProgressStyle::with_template("{msg:>12.bold} retrying download").unwrap()); + self.progress.set_style( + ProgressStyle::with_template("{msg:>12.bold} retrying download...").unwrap(), + ); + } + + pub(crate) fn installing(&self) { + self.progress.set_style( + ProgressStyle::with_template( + "{msg:>12.bold} installing {spinner:.green}", + ) + .unwrap() + .tick_chars(r"|/-\ "), + ); + self.progress.enable_steady_tick(Duration::from_millis(100)); + } + + pub(crate) fn installed(&self) { + self.progress.set_style( + ProgressStyle::with_template("{msg:>12.bold} installed").unwrap(), + ); + self.progress.finish(); } } diff --git a/src/dist/manifestation.rs b/src/dist/manifestation.rs index 577b2a25af..05ddf6a093 100644 --- a/src/dist/manifestation.rs +++ b/src/dist/manifestation.rs @@ -744,17 +744,7 @@ impl<'a> ComponentBinary<'a> { let short_pkg_name = component.short_name_in_manifest(); let short_name = component.short_name(new_manifest); - match &component.target { - Some(t) if t != &manifestation.target_triple => { - info!("installing component {short_name}"); - } - _ => { - info!( - "installing component {short_name} for target {}", - manifestation.target_triple - ) - } - } + self.status.installing(); let reader = utils::FileReaderWithProgress::new_file(&installer_file)?; let package = match self.binary.compression { @@ -769,11 +759,13 @@ impl<'a> ComponentBinary<'a> { return Err(RustupError::CorruptComponent(short_name).into()); } - package.install( + let tx = package.install( &manifestation.installation, &pkg_name, Some(short_pkg_name), tx, - ) + ); + self.status.installed(); + tx } } From 7dce0f5974bfa45406e03bad5998fd227049ee65 Mon Sep 17 00:00:00 2001 From: Francisco Gouveia Date: Tue, 21 Oct 2025 10:48:19 +0100 Subject: [PATCH 2/2] progress: modify progress bar's states to be column-aligned --- src/dist/download.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dist/download.rs b/src/dist/download.rs index ff998108dc..462c969577 100644 --- a/src/dist/download.rs +++ b/src/dist/download.rs @@ -194,7 +194,7 @@ impl<'a> DownloadCfg<'a> { let progress = ProgressBar::hidden(); progress.set_style( ProgressStyle::with_template( - "{msg:>12.bold} [{bar:40}] {bytes}/{total_bytes} ({bytes_per_sec}, ETA: {eta})", + "{msg:>12.bold} [{bar:30}] {bytes}/{total_bytes} ({bytes_per_sec}, ETA: {eta})", ) .unwrap() .progress_chars("## "), @@ -260,7 +260,7 @@ impl DownloadStatus { *retry_time = None; self.progress.set_style( ProgressStyle::with_template( - "{msg:>12.bold} [{bar:40}] {bytes}/{total_bytes} ({bytes_per_sec}, ETA: {eta})", + "{msg:>12.bold} [{bar:30}] {bytes}/{total_bytes} ({bytes_per_sec}, ETA: {eta})", ) .unwrap() .progress_chars("## "), @@ -269,7 +269,7 @@ impl DownloadStatus { pub(crate) fn finished(&self) { self.progress.set_style( - ProgressStyle::with_template("{msg:>12.bold} pending installation") + ProgressStyle::with_template("{msg:>12.bold} pending installation {total_bytes:>10}") .unwrap(), ); self.progress.tick(); // A tick is needed for the new style to appear, as it is static. @@ -293,7 +293,7 @@ impl DownloadStatus { pub(crate) fn installing(&self) { self.progress.set_style( ProgressStyle::with_template( - "{msg:>12.bold} installing {spinner:.green}", + "{msg:>12.bold} installing {spinner:.green} {total_bytes:>18}", ) .unwrap() .tick_chars(r"|/-\ "), @@ -303,7 +303,7 @@ impl DownloadStatus { pub(crate) fn installed(&self) { self.progress.set_style( - ProgressStyle::with_template("{msg:>12.bold} installed").unwrap(), + ProgressStyle::with_template("{msg:>12.bold} installed {total_bytes:>21}").unwrap(), ); self.progress.finish(); }