diff --git a/src/config/rt/build.rs b/src/config/rt/build.rs index 5a879b12..39f96396 100644 --- a/src/config/rt/build.rs +++ b/src/config/rt/build.rs @@ -6,7 +6,7 @@ use crate::config::{ Hooks, }; use anyhow::{ensure, Context}; -use std::{collections::HashMap, io::ErrorKind, ops::Deref, path::PathBuf}; +use std::{collections::HashMap, ops::Deref, path::PathBuf}; /// Config options for the cargo build command #[derive(Clone, Debug)] @@ -136,14 +136,10 @@ impl RtcBuild { // we would want to avoid such an action at this layer, however to ensure that other layers // have a reliable FS path to work with, we make an exception here. let final_dist = core.working_directory.join(&build.dist); - if !final_dist.exists() { - std::fs::create_dir(&final_dist) - .or_else(|err| match err.kind() { - ErrorKind::AlreadyExists => Ok(()), - _ => Err(err), - }) - .with_context(|| format!("error creating final dist directory {final_dist:?}"))?; - } + + std::fs::create_dir_all(&final_dist) + .with_context(|| format!("error creating final dist directory {final_dist:?}"))?; + let final_dist = final_dist .canonicalize() .context("error taking canonical path to dist dir")?; diff --git a/src/pipelines/copy_dir_test.rs b/src/pipelines/copy_dir_test.rs index fded4dcd..4d8ea9e1 100644 --- a/src/pipelines/copy_dir_test.rs +++ b/src/pipelines/copy_dir_test.rs @@ -13,7 +13,7 @@ async fn setup_test_config() -> Result<(tempfile::TempDir, Arc, PathBu let tmpdir = tempfile::tempdir().context("error building tempdir for test")?; let cfg = Arc::new(RtcBuild::new_test(tmpdir.path()).await?); let asset_dir = tmpdir.path().join("test_dir"); - tokio::fs::create_dir(&asset_dir) + tokio::fs::create_dir_all(&asset_dir) .await .context("error creating test dir")?; let asset_file = asset_dir.join("test_file"); diff --git a/src/tools.rs b/src/tools.rs index d2c63846..3f5b58a4 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -542,12 +542,7 @@ mod archive { } } Self::None(in_file) => { - let create_dir_result = std::fs::create_dir(target_directory); - if let Err(e) = &create_dir_result { - if e.kind() != std::io::ErrorKind::AlreadyExists { - create_dir_result.context("failed to open file for")?; - } - } + std::fs::create_dir_all(target_directory).context("failed to open file for")?; let mut out_file_path = target_directory.to_path_buf(); out_file_path.push(file);