Skip to content

Commit 37bcf4d

Browse files
committed
notifications: log directly on missing components
1 parent ffcd229 commit 37bcf4d

File tree

3 files changed

+11
-23
lines changed

3 files changed

+11
-23
lines changed

src/dist/manifestation.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use anyhow::{Context, Result, anyhow, bail};
1010
use futures_util::stream::StreamExt;
1111
use std::sync::Arc;
1212
use tokio::sync::Semaphore;
13-
use tracing::info;
13+
use tracing::{info, warn};
1414
use url::Url;
1515

1616
use crate::dist::component::{
@@ -229,13 +229,7 @@ impl Manifestation {
229229
component.target.as_ref(),
230230
));
231231

232-
tx = self.uninstall_component(
233-
component,
234-
new_manifest,
235-
tx,
236-
&download_cfg.notify_handler,
237-
download_cfg.process,
238-
)?;
232+
tx = self.uninstall_component(component, new_manifest, tx, download_cfg.process)?;
239233
}
240234

241235
// Install components
@@ -313,7 +307,6 @@ impl Manifestation {
313307
&self,
314308
manifest: &Manifest,
315309
tmp_cx: &temp::Context,
316-
notify_handler: &dyn Fn(Notification<'_>),
317310
process: &Process,
318311
) -> Result<()> {
319312
let prefix = self.installation.prefix();
@@ -331,7 +324,7 @@ impl Manifestation {
331324
tx.remove_file("dist config", rel_config_path)?;
332325

333326
for component in config.components {
334-
tx = self.uninstall_component(&component, manifest, tx, notify_handler, process)?;
327+
tx = self.uninstall_component(&component, manifest, tx, process)?;
335328
}
336329
tx.commit();
337330

@@ -343,7 +336,6 @@ impl Manifestation {
343336
component: &Component,
344337
manifest: &Manifest,
345338
mut tx: Transaction<'a>,
346-
notify_handler: &dyn Fn(Notification<'_>),
347339
process: &Process,
348340
) -> Result<Transaction<'a>> {
349341
// For historical reasons, the rust-installer component
@@ -357,9 +349,10 @@ impl Manifestation {
357349
} else if let Some(c) = self.installation.find(short_name)? {
358350
tx = c.uninstall(tx, process)?;
359351
} else {
360-
notify_handler(Notification::MissingInstalledComponent(
361-
&component.short_name(manifest),
362-
));
352+
warn!(
353+
component = %component.short_name(manifest),
354+
"component not found during uninstall"
355+
);
363356
}
364357

365358
Ok(tx)

src/dist/manifestation/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ impl TestContext {
540540
let manifestation = Manifestation::open(self.prefix.clone(), trip)?;
541541
let manifest = manifestation.load_manifest()?.unwrap();
542542

543-
manifestation.uninstall(&manifest, &self.tmp_cx, &|_| (), &self.tp.process)?;
543+
manifestation.uninstall(&manifest, &self.tmp_cx, &self.tp.process)?;
544544

545545
Ok(())
546546
}

src/notifications.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use crate::{dist::ToolchainDesc, toolchain::ToolchainName, utils::notify::Notifi
1313
pub(crate) enum Notification<'a> {
1414
FileAlreadyDownloaded,
1515
CachedFileChecksumFailed,
16-
MissingInstalledComponent(&'a str),
1716
/// The URL of the download is passed as the last argument, to allow us to track concurrent downloads.
1817
DownloadingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>, &'a str),
1918
InstallingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>),
@@ -79,10 +78,9 @@ impl Notification<'_> {
7978
| SkippingNightlyMissingComponent(_, _, _)
8079
| RetryingDownload(_)
8180
| DownloadedManifest(_, _) => NotificationLevel::Info,
82-
MissingInstalledComponent(_)
83-
| CachedFileChecksumFailed
84-
| ForcingUnavailableComponent(_)
85-
| StrayHash(_) => NotificationLevel::Warn,
81+
CachedFileChecksumFailed | ForcingUnavailableComponent(_) | StrayHash(_) => {
82+
NotificationLevel::Warn
83+
}
8684
SetDefaultBufferSize(_) => NotificationLevel::Trace,
8785
DownloadingFile(_)
8886
| DownloadContentLengthReceived(_, _)
@@ -118,9 +116,6 @@ impl Display for Notification<'_> {
118116
match self {
119117
FileAlreadyDownloaded => write!(f, "reusing previously downloaded file"),
120118
CachedFileChecksumFailed => write!(f, "bad checksum for cached download"),
121-
MissingInstalledComponent(c) => {
122-
write!(f, "during uninstall component {c} was not found")
123-
}
124119
DownloadingComponent(c, h, t, _) => {
125120
if Some(h) == t.as_ref() || t.is_none() {
126121
write!(f, "downloading component '{c}'")

0 commit comments

Comments
 (0)