Skip to content

Commit d6b589c

Browse files
committed
notifications: log directly when removing stray hash files
1 parent 4630803 commit d6b589c

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

src/dist/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use tracing::{debug, info, warn};
1616
use crate::{
1717
config::{Cfg, dist_root_server},
1818
errors::RustupError,
19-
notifications::Notification,
2019
process::Process,
2120
toolchain::ToolchainName,
2221
utils,
@@ -912,7 +911,7 @@ pub(crate) async fn update_from_dist(
912911
if let Some(hash) = opts.update_hash {
913912
// fresh_install means the toolchain isn't present, but hash_exists means there is a stray hash file
914913
if fresh_install && Path::exists(hash) {
915-
(opts.dl_cfg.notify_handler)(Notification::StrayHash(hash));
914+
warn!(file = %hash.display(), "removing stray hash file in order to continue");
916915
std::fs::remove_file(hash)?;
917916
}
918917
}

src/notifications.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub(crate) enum Notification<'a> {
1414
CachedFileChecksumFailed,
1515
/// The URL of the download is passed as the last argument, to allow us to track concurrent downloads.
1616
DownloadingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>, &'a str),
17-
StrayHash(&'a Path),
1817
RetryingDownload(&'a str),
1918
DownloadingFile(&'a Url),
2019
/// Received the Content-Length of the to-be downloaded data with
@@ -62,7 +61,7 @@ impl Notification<'_> {
6261
match self {
6362
FileAlreadyDownloaded => NotificationLevel::Debug,
6463
DownloadingComponent(_, _, _, _) | RetryingDownload(_) => NotificationLevel::Info,
65-
CachedFileChecksumFailed | StrayHash(_) => NotificationLevel::Warn,
64+
CachedFileChecksumFailed => NotificationLevel::Warn,
6665
SetDefaultBufferSize(_) => NotificationLevel::Trace,
6766
DownloadingFile(_)
6867
| DownloadContentLengthReceived(_, _)
@@ -105,11 +104,6 @@ impl Display for Notification<'_> {
105104
write!(f, "downloading component '{}' for '{}'", c, t.unwrap())
106105
}
107106
}
108-
StrayHash(path) => write!(
109-
f,
110-
"removing stray hash found at '{}' in order to continue",
111-
path.display()
112-
),
113107
RetryingDownload(url) => write!(f, "retrying download for '{url}'"),
114108
SetDefaultBufferSize(size) => write!(
115109
f,

tests/suite/cli_v2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ async fn warn_about_and_remove_stray_hash() {
19141914
.await
19151915
.with_stderr(snapbox::str![[r#"
19161916
...
1917-
warn: removing stray hash found at '[..]/update-hashes/nightly-[HOST_TRIPLE]' in order to continue
1917+
warn: removing stray hash file in order to continue file=[..]/update-hashes/nightly-[HOST_TRIPLE]
19181918
...
19191919
"#]])
19201920
.is_ok();

0 commit comments

Comments
 (0)