Create $RUSTUP_HOME/tmp if needed (#365)

* fix: Create $RUSTUP_HOME/tmp if needed

* style: Simplify create_dir_all error

* docs: Update CHANGELOG.md

* perf: Fix Windows includes
This commit is contained in:
Sergio Gasquez Arcos 2023-10-04 09:49:13 +02:00 committed by GitHub
parent 09b94cd9e0
commit 107de282ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View File

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
### Fixed
- Create $RUSTUP_HOME/tmp if needed (#365)
- Complete Xtensa Rust versions when provided one is incompleted (#366)
### Removed

View File

@ -65,9 +65,8 @@ pub async fn download_file(
emoji::WRENCH,
output_directory
);
if create_dir_all(output_directory).is_err() {
return Err(Error::CreateDirectory(output_directory.to_string()));
}
create_dir_all(output_directory)
.map_err(|_| Error::CreateDirectory(output_directory.to_string()))?;
}
info!(
"{} Downloading file '{}' from '{}'",

View File

@ -17,6 +17,8 @@ use directories::BaseDirs;
use log::{debug, info, warn};
use miette::Result;
use regex::Regex;
#[cfg(unix)]
use std::fs::create_dir_all;
use std::{
env,
fmt::Debug,
@ -225,7 +227,13 @@ impl Installable for XtensaRust {
#[cfg(unix)]
if cfg!(unix) {
let tmp_dir = tempdir_in(get_rustup_home().join("tmp"))?;
let path = get_rustup_home().join("tmp");
if !path.exists() {
info!("{} Creating directory: '{}'", emoji::WRENCH, path.display());
create_dir_all(&path)
.map_err(|_| Error::CreateDirectory(path.display().to_string()))?;
}
let tmp_dir = tempdir_in(path)?;
let tmp_dir_path = &tmp_dir.path().display().to_string();
download_file(