Skip to content

Commit 754886f

Browse files
committed
Dead code removal
1 parent 8128266 commit 754886f

File tree

3 files changed

+1
-100
lines changed

3 files changed

+1
-100
lines changed

src/errors.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,6 @@ error_chain! {
189189
description("invalid toolchain name")
190190
display("invalid toolchain name: '{}'", t)
191191
}
192-
InvalidCustomToolchainName(t: String) {
193-
description("invalid custom toolchain name")
194-
display("invalid custom toolchain name: '{}'", t)
195-
}
196192
InvalidProfile(t: String) {
197193
description("invalid profile name")
198194
display("invalid profile name: '{}'; valid names are: {}", t, valid_profile_names())

src/install.rs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
//! Installation and upgrade of both distribution-managed and local
22
//! toolchains
33
4-
use crate::dist::component::{Components, Package, TarGzPackage, Transaction};
54
use crate::dist::dist;
65
use crate::dist::download::DownloadCfg;
76
use crate::dist::prefix::InstallPrefix;
8-
use crate::dist::temp;
97
use crate::dist::Notification;
108
use crate::errors::Result;
119
use crate::notifications::Notification as RootNotification;
@@ -17,7 +15,6 @@ use std::path::Path;
1715
pub enum InstallMethod<'a> {
1816
Copy(&'a Path, &'a CustomToolchain<'a>),
1917
Link(&'a Path, &'a CustomToolchain<'a>),
20-
Installer(&'a Path, &'a temp::Cfg, &'a CustomToolchain<'a>),
2118
// bool is whether to force an update
2219
Dist {
2320
desc: &'a dist::ToolchainDesc,
@@ -86,7 +83,7 @@ impl<'a> InstallMethod<'a> {
8683
if path.exists() {
8784
// Don't uninstall first for Dist method
8885
match self {
89-
InstallMethod::Dist { .. } | InstallMethod::Installer(..) => {}
86+
InstallMethod::Dist { .. } => {}
9087
_ => {
9188
uninstall(path, notify_handler)?;
9289
}
@@ -102,10 +99,6 @@ impl<'a> InstallMethod<'a> {
10299
utils::symlink_dir(src, &path, notify_handler)?;
103100
Ok(true)
104101
}
105-
InstallMethod::Installer(src, temp_cfg, ..) => {
106-
InstallMethod::tar_gz(src, path, &temp_cfg, notify_handler)?;
107-
Ok(true)
108-
}
109102
InstallMethod::Dist {
110103
desc,
111104
profile,
@@ -145,34 +138,6 @@ impl<'a> InstallMethod<'a> {
145138
}
146139
}
147140
}
148-
149-
fn tar_gz(
150-
src: &Path,
151-
path: &Path,
152-
temp_cfg: &temp::Cfg,
153-
notify_handler: &dyn Fn(Notification<'_>),
154-
) -> Result<()> {
155-
notify_handler(Notification::Extracting(src, path));
156-
157-
let prefix = InstallPrefix::from(path.to_owned());
158-
let installation = Components::open(prefix.clone())?;
159-
let notification_converter = |notification: crate::utils::Notification<'_>| {
160-
notify_handler(notification.into());
161-
};
162-
let reader = utils::FileReaderWithProgress::new_file(&src, &notification_converter)?;
163-
let package: &dyn Package =
164-
&TarGzPackage::new(reader, temp_cfg, Some(&notification_converter))?;
165-
166-
let mut tx = Transaction::new(prefix, temp_cfg, notify_handler);
167-
168-
for component in package.components() {
169-
tx = package.install(&installation, &component, None, tx)?;
170-
}
171-
172-
tx.commit();
173-
174-
Ok(())
175-
}
176141
}
177142

178143
pub fn uninstall(path: &Path, notify_handler: &dyn Fn(Notification<'_>)) -> Result<()> {

src/toolchain.rs

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use std::process::{Command, Stdio};
2222
use std::str::FromStr;
2323
use std::time::Duration;
2424

25-
use url::Url;
2625
use wait_timeout::ChildExt;
2726

2827
/// An installed toolchain
@@ -151,65 +150,6 @@ impl<'a> Toolchain<'a> {
151150
== Some(true)
152151
}
153152

154-
// TO be a downcast or something.
155-
fn ensure_custom(&self) -> Result<()> {
156-
if !self.is_custom() {
157-
Err(crate::ErrorKind::InvalidCustomToolchainName(self.name.to_string()).into())
158-
} else {
159-
Ok(())
160-
}
161-
}
162-
163-
// Custom only. Installed or not installed.
164-
pub fn install_from_installers(&self, installers: &[&OsStr]) -> Result<()> {
165-
self.ensure_custom()?;
166-
167-
let custom = CustomToolchain::new(&self)?;
168-
self.remove()?;
169-
170-
// FIXME: This should do all downloads first, then do
171-
// installs, and do it all in a single transaction.
172-
for installer in installers {
173-
let installer_str = installer.to_str().unwrap_or("bogus");
174-
match installer_str.rfind('.') {
175-
Some(i) => {
176-
let extension = &installer_str[i + 1..];
177-
if extension != "gz" {
178-
return Err(ErrorKind::BadInstallerType(extension.to_string()).into());
179-
}
180-
}
181-
None => return Err(ErrorKind::BadInstallerType(String::from("(none)")).into()),
182-
}
183-
184-
// FIXME: Pretty hacky
185-
let is_url = installer_str.starts_with("file://")
186-
|| installer_str.starts_with("http://")
187-
|| installer_str.starts_with("https://");
188-
let url = Url::parse(installer_str).ok();
189-
let url = if is_url { url } else { None };
190-
if let Some(url) = url {
191-
// Download to a local file
192-
let local_installer = self.cfg.temp_cfg.new_file_with_ext("", ".tar.gz")?;
193-
utils::download_file(&url, &local_installer, None, &|n| {
194-
(self.cfg.notify_handler)(n.into())
195-
})?;
196-
InstallMethod::Installer(&local_installer, &self.cfg.temp_cfg, &custom)
197-
.install(&self)?;
198-
} else {
199-
// If installer is a filename
200-
201-
// No need to download
202-
let local_installer = Path::new(installer);
203-
204-
// Install from file
205-
InstallMethod::Installer(&local_installer, &self.cfg.temp_cfg, &custom)
206-
.install(&self)?;
207-
}
208-
}
209-
210-
Ok(())
211-
}
212-
213153
// Both Distributable and Custom; Installed only.
214154
pub fn create_command<T: AsRef<OsStr>>(&self, binary: T) -> Result<Command> {
215155
if !self.exists() {

0 commit comments

Comments
 (0)