Skip to content

Commit 56e2018

Browse files
committed
Remove install_if_not_installed
This function had only one caller, no conditionals, and wasn't looped on.
1 parent 41058fa commit 56e2018

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

src/toolchain.rs

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,6 @@ impl<'a> Toolchain<'a> {
139139
Ok(())
140140
}
141141

142-
// Custom and Distributable, Installed and not installed.
143-
// Perhaps make into a helper?
144-
fn install_if_not_installed(&self, install_method: InstallMethod<'_>) -> Result<UpdateStatus> {
145-
assert!(self.is_valid_install_method(install_method));
146-
(self.cfg.notify_handler)(Notification::LookingForToolchain(&self.name));
147-
if !self.exists() {
148-
Ok(install_method.install(&self)?)
149-
} else {
150-
(self.cfg.notify_handler)(Notification::UsingExistingToolchain(&self.name));
151-
Ok(UpdateStatus::Unchanged)
152-
}
153-
}
154142
// Custom and Distributable. Installed and not installed (because of install_from_dist_if_not_installed) Goes away?
155143
// Or perhaps a trait.
156144
pub fn is_valid_install_method(&self, install_method: InstallMethod<'_>) -> bool {
@@ -750,18 +738,25 @@ impl<'a> DistributableToolchain<'a> {
750738
// Installed or not installed.
751739
pub fn install_from_dist_if_not_installed(&self) -> Result<UpdateStatus> {
752740
let update_hash = self.update_hash()?;
753-
self.0.install_if_not_installed(InstallMethod::Dist(
754-
&self.desc()?,
755-
self.0.cfg.get_profile()?,
756-
Some(&update_hash),
757-
self.0.download_cfg(),
758-
false,
759-
false,
760-
false,
761-
None,
762-
&[],
763-
&[],
764-
))
741+
(self.0.cfg.notify_handler)(Notification::LookingForToolchain(&self.0.name));
742+
if !self.0.exists() {
743+
Ok(InstallMethod::Dist(
744+
&self.desc()?,
745+
self.0.cfg.get_profile()?,
746+
Some(&update_hash),
747+
self.0.download_cfg(),
748+
false,
749+
false,
750+
false,
751+
None,
752+
&[],
753+
&[],
754+
)
755+
.install(&self.0)?)
756+
} else {
757+
(self.0.cfg.notify_handler)(Notification::UsingExistingToolchain(&self.0.name));
758+
Ok(UpdateStatus::Unchanged)
759+
}
765760
}
766761

767762
// Installed only.

0 commit comments

Comments
 (0)