Skip to content

Commit

Permalink
fix: Fix tempdirs cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioGasquez committed Sep 7, 2023
1 parent f0148ba commit 2ac988b
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/toolchain/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,12 @@ impl Installable for XtensaRust {

#[cfg(unix)]
if cfg!(unix) {
let temp_rust_dir = tempfile::TempDir::new()
.unwrap()
.into_path()
.display()
.to_string();
let rust_dir = tempfile::TempDir::new()?;
let rust_dir_path = &rust_dir.path().display().to_string();
download_file(
self.dist_url.clone(),
"rust.tar.xz",
&temp_rust_dir,
rust_dir_path,
true,
false,
)
Expand All @@ -233,7 +230,7 @@ impl Installable for XtensaRust {
.arg("bash")
.arg(format!(
"{}/rust-nightly-{}/install.sh",
temp_rust_dir, &self.host_triple,
rust_dir_path, &self.host_triple,
))
.arg(format!(
"--destdir={}",
Expand All @@ -251,15 +248,12 @@ impl Installable for XtensaRust {
return Err(Error::XtensaRust);
}

let temp_rust_src_dir = tempfile::TempDir::new()
.unwrap()
.into_path()
.display()
.to_string();
let rust_src_dir = tempfile::TempDir::new()?;
let rust_src_dir_path = &rust_src_dir.path().display().to_string();
download_file(
self.src_dist_url.clone(),
"rust-src.tar.xz",
&temp_rust_src_dir,
rust_src_dir_path,
true,
false,
)
Expand All @@ -270,7 +264,7 @@ impl Installable for XtensaRust {
);
if !Command::new("/usr/bin/env")
.arg("bash")
.arg(format!("{}/rust-src-nightly/install.sh", temp_rust_src_dir))
.arg(format!("{}/rust-src-nightly/install.sh", rust_src_dir_path))
.arg(format!(
"--destdir={}",
self.toolchain_destination.display()
Expand Down

0 comments on commit 2ac988b

Please sign in to comment.