Skip to content

Commit 3c8457c

Browse files
committed
Remove components if they don't exist anymore during update
1 parent 444983e commit 3c8457c

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/rustup-dist/src/manifestation.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ impl Update {
475475
rust_target_package,
476476
new_manifest,
477477
&changes,
478+
notify_handler,
478479
);
479480

480481
// If this is a full upgrade then the list of components to
@@ -520,6 +521,7 @@ impl Update {
520521
rust_target_package: &TargetedPackage,
521522
new_manifest: &Manifest,
522523
changes: &Changes,
524+
notify_handler: &Fn(Notification),
523525
) {
524526
// Add components required by the package, according to the
525527
// manifest
@@ -559,7 +561,14 @@ impl Update {
559561
if component_is_present {
560562
self.final_component_list.push(existing_component.clone());
561563
} else {
562-
self.missing_components.push(existing_component.clone());
564+
// If a component is not available anymore for the target remove it
565+
// This prevents errors when trying to update to a newer version with
566+
// a removed component.
567+
self.components_to_uninstall.push(existing_component.clone());
568+
notify_handler(Notification::ComponentUnavailable(
569+
&existing_component.pkg,
570+
existing_component.target.as_ref(),
571+
));
563572
}
564573
}
565574
}

src/rustup-dist/src/notifications.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub enum Notification<'a> {
3131
DownloadedManifest(&'a str, Option<&'a str>),
3232
DownloadingLegacyManifest,
3333
ManifestChecksumFailedHack,
34+
ComponentUnavailable(&'a str, Option<&'a TargetTriple>),
3435
}
3536

3637
impl<'a> From<rustup_utils::Notification<'a>> for Notification<'a> {
@@ -68,7 +69,8 @@ impl<'a> Notification<'a> {
6869
CantReadUpdateHash(_)
6970
| ExtensionNotInstalled(_)
7071
| MissingInstalledComponent(_)
71-
| CachedFileChecksumFailed => NotificationLevel::Warn,
72+
| CachedFileChecksumFailed
73+
| ComponentUnavailable(_, _) => NotificationLevel::Warn,
7274
NonFatalError(_) => NotificationLevel::Error,
7375
}
7476
}
@@ -132,6 +134,13 @@ impl<'a> Display for Notification<'a> {
132134
ManifestChecksumFailedHack => {
133135
write!(f, "update not yet available, sorry! try again later")
134136
}
137+
ComponentUnavailable(pkg, toolchain) => {
138+
if let Some(tc) = toolchain {
139+
write!(f, "component '{}' is not available anymore on target '{}'", pkg, tc)
140+
} else {
141+
write!(f, "component '{}' is not available anymore", pkg)
142+
}
143+
}
135144
}
136145
}
137146
}

0 commit comments

Comments
 (0)