Skip to content

Commit e152dc7

Browse files
committed
Clean up some manifestation logic
1 parent cb729c7 commit e152dc7

File tree

1 file changed

+14
-30
lines changed

1 file changed

+14
-30
lines changed

src/dist/manifestation.rs

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -130,25 +130,19 @@ impl Manifestation {
130130
}
131131

132132
// Validate that the requested components are available
133-
match update.unavailable_components(new_manifest, toolchain_str) {
134-
Ok(_) => {}
135-
Err(e) => {
136-
if force_update {
137-
if let Ok(RustupError::RequestedComponentsUnavailable { components, .. }) =
138-
e.downcast::<RustupError>()
139-
{
140-
for component in &components {
141-
(download_cfg.notify_handler)(
142-
Notification::ForcingUnavailableComponent(
143-
component.name(new_manifest).as_str(),
144-
),
145-
);
146-
}
147-
update.drop_components_to_install(&components);
148-
}
149-
} else {
150-
return Err(e);
133+
if let Err(e) = update.unavailable_components(new_manifest, toolchain_str) {
134+
if !force_update {
135+
return Err(e);
136+
}
137+
if let Ok(RustupError::RequestedComponentsUnavailable { components, .. }) =
138+
e.downcast::<RustupError>()
139+
{
140+
for component in &components {
141+
(download_cfg.notify_handler)(Notification::ForcingUnavailableComponent(
142+
&component.name(new_manifest),
143+
));
151144
}
145+
update.drop_components_to_install(&components);
152146
}
153147
}
154148

@@ -678,18 +672,8 @@ impl Update {
678672
}
679673

680674
fn drop_components_to_install(&mut self, to_drop: &[Component]) {
681-
let components: Vec<_> = self
682-
.components_to_install
683-
.drain(..)
684-
.filter(|c| !to_drop.contains(c))
685-
.collect();
686-
self.components_to_install.extend(components);
687-
let final_components: Vec<_> = self
688-
.final_component_list
689-
.drain(..)
690-
.filter(|c| !to_drop.contains(c))
691-
.collect();
692-
self.final_component_list = final_components;
675+
self.components_to_install.retain(|c| !to_drop.contains(c));
676+
self.final_component_list.retain(|c| !to_drop.contains(c));
693677
}
694678

695679
/// Map components to urls and hashes

0 commit comments

Comments
 (0)