Skip to content

Commit 829fa3c

Browse files
FranciscoTGouveiadjc
authored andcommitted
installations: handle installation of components through progress bars
1 parent 32141c9 commit 829fa3c

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

src/dist/download.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ impl DownloadStatus {
269269

270270
pub(crate) fn finished(&self) {
271271
self.progress.set_style(
272-
ProgressStyle::with_template("{msg:>12.bold} downloaded {total_bytes} in {elapsed}")
272+
ProgressStyle::with_template("{msg:>12.bold} pending installation")
273273
.unwrap(),
274274
);
275-
self.progress.finish();
275+
self.progress.tick(); // A tick is needed for the new style to appear, as it is static.
276276
}
277277

278278
pub(crate) fn failed(&self) {
@@ -285,8 +285,27 @@ impl DownloadStatus {
285285

286286
pub(crate) fn retrying(&self) {
287287
*self.retry_time.lock().unwrap() = Some(Instant::now());
288-
self.progress
289-
.set_style(ProgressStyle::with_template("{msg:>12.bold} retrying download").unwrap());
288+
self.progress.set_style(
289+
ProgressStyle::with_template("{msg:>12.bold} retrying download...").unwrap(),
290+
);
291+
}
292+
293+
pub(crate) fn installing(&self) {
294+
self.progress.set_style(
295+
ProgressStyle::with_template(
296+
"{msg:>12.bold} installing {spinner:.green}",
297+
)
298+
.unwrap()
299+
.tick_chars(r"|/-\ "),
300+
);
301+
self.progress.enable_steady_tick(Duration::from_millis(100));
302+
}
303+
304+
pub(crate) fn installed(&self) {
305+
self.progress.set_style(
306+
ProgressStyle::with_template("{msg:>12.bold} installed").unwrap(),
307+
);
308+
self.progress.finish();
290309
}
291310
}
292311

src/dist/manifestation.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -744,17 +744,7 @@ impl<'a> ComponentBinary<'a> {
744744
let short_pkg_name = component.short_name_in_manifest();
745745
let short_name = component.short_name(new_manifest);
746746

747-
match &component.target {
748-
Some(t) if t != &manifestation.target_triple => {
749-
info!("installing component {short_name}");
750-
}
751-
_ => {
752-
info!(
753-
"installing component {short_name} for target {}",
754-
manifestation.target_triple
755-
)
756-
}
757-
}
747+
self.status.installing();
758748

759749
let reader = utils::FileReaderWithProgress::new_file(&installer_file)?;
760750
let package = match self.binary.compression {
@@ -769,11 +759,13 @@ impl<'a> ComponentBinary<'a> {
769759
return Err(RustupError::CorruptComponent(short_name).into());
770760
}
771761

772-
package.install(
762+
let tx = package.install(
773763
&manifestation.installation,
774764
&pkg_name,
775765
Some(short_pkg_name),
776766
tx,
777-
)
767+
);
768+
self.status.installed();
769+
tx
778770
}
779771
}

0 commit comments

Comments
 (0)