Skip to content

Commit fa4cbde

Browse files
committed
notifications: log directly when uninstalling toolchains
1 parent e6ef727 commit fa4cbde

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

src/notifications.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::path::{Path, PathBuf};
33

44
use crate::dist::TargetTriple;
55
use crate::settings::MetadataVersion;
6+
use crate::utils::notify::NotificationLevel;
67
use crate::utils::units;
7-
use crate::{toolchain::ToolchainName, utils::notify::NotificationLevel};
88

99
#[derive(Debug)]
1010
pub(crate) enum Notification<'a> {
@@ -26,8 +26,6 @@ pub(crate) enum Notification<'a> {
2626
/// member, but the notification callback is already narrowed to
2727
/// utils::notifications by the time tar unpacking is called.
2828
SetDefaultBufferSize(usize),
29-
UninstallingToolchain(&'a ToolchainName),
30-
UninstalledToolchain(&'a ToolchainName),
3129
UpgradingMetadata(MetadataVersion, MetadataVersion),
3230
MetadataUpgradeNotNeeded(MetadataVersion),
3331
ReadMetadataVersion(MetadataVersion),
@@ -52,10 +50,7 @@ impl Notification<'_> {
5250
| DownloadFinished(_)
5351
| DownloadFailed(_) => NotificationLevel::Debug,
5452
ReadMetadataVersion(_) => NotificationLevel::Debug,
55-
UninstallingToolchain(_)
56-
| UninstalledToolchain(_)
57-
| UpgradingMetadata(_, _)
58-
| MetadataUpgradeNotNeeded(_) => NotificationLevel::Info,
53+
UpgradingMetadata(_, _) | MetadataUpgradeNotNeeded(_) => NotificationLevel::Info,
5954
UpgradeRemovesToolchains | DuplicateToolchainFile { .. } => NotificationLevel::Warn,
6055
}
6156
}
@@ -84,8 +79,6 @@ impl Display for Notification<'_> {
8479
DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()),
8580
DownloadFinished(_) => write!(f, "download finished"),
8681
DownloadFailed(_) => write!(f, "download failed"),
87-
UninstallingToolchain(name) => write!(f, "uninstalling toolchain '{name}'"),
88-
UninstalledToolchain(name) => write!(f, "toolchain '{name}' uninstalled"),
8982
UpgradingMetadata(from_ver, to_ver) => write!(
9083
f,
9184
"upgrading metadata version from '{from_ver}' to '{to_ver}'"

src/toolchain.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use crate::{
2828
prefix::InstallPrefix,
2929
},
3030
env_var, install,
31-
notifications::Notification,
3231
utils::{self, raw::open_dir_following_links},
3332
};
3433

@@ -544,7 +543,7 @@ impl<'a> Toolchain<'a> {
544543
};
545544
let fs_modified = match Self::exists(cfg, &(&name).into())? {
546545
true => {
547-
(cfg.notify_handler)(Notification::UninstallingToolchain(&name));
546+
info!("uninstalling toolchain {name}");
548547
let installed_paths = match &name {
549548
ToolchainName::Custom(_) => Ok(vec![InstalledPath::Dir { path: &path }]),
550549
ToolchainName::Official(desc) => cfg.installed_paths(desc, &path),
@@ -562,7 +561,7 @@ impl<'a> Toolchain<'a> {
562561
false => {
563562
// Might be a dangling symlink
564563
if path.is_symlink() {
565-
(cfg.notify_handler)(Notification::UninstallingToolchain(&name));
564+
info!("uninstalling toolchain {name}");
566565
fs::remove_dir_all(&path)?;
567566
true
568567
} else {
@@ -579,7 +578,7 @@ impl<'a> Toolchain<'a> {
579578
};
580579

581580
if !path.is_symlink() && !path.exists() && fs_modified {
582-
(cfg.notify_handler)(Notification::UninstalledToolchain(&name));
581+
info!("toolchain {name} uninstalled");
583582
}
584583
Ok(())
585584
}

tests/suite/cli_misc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,8 +1028,8 @@ test
10281028
.expect(["rustup", "toolchain", "uninstall", "test"])
10291029
.await
10301030
.with_stderr(snapbox::str![[r#"
1031-
info: uninstalling toolchain 'test'
1032-
info: toolchain 'test' uninstalled
1031+
info: uninstalling toolchain test
1032+
info: toolchain test uninstalled
10331033
10341034
"#]])
10351035
.is_ok();

tests/suite/cli_v2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ async fn remove_toolchain_ignore_trailing_slash() {
375375
.await
376376
.with_stderr(snapbox::str![[r#"
377377
...
378-
info: toolchain 'dev' uninstalled
378+
info: toolchain dev uninstalled
379379
...
380380
"#]])
381381
.is_ok();
@@ -397,7 +397,7 @@ info: toolchain 'dev' uninstalled
397397
.await
398398
.with_stderr(snapbox::str![[r#"
399399
...
400-
info: toolchain 'nightly-[HOST_TRIPLE]' uninstalled
400+
info: toolchain nightly-[HOST_TRIPLE] uninstalled
401401
...
402402
"#]])
403403
.is_ok();

0 commit comments

Comments
 (0)