Skip to content

Commit

Permalink
CreateOrInsertIntoFile: create parent dir if nonexistent (#1434)
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-h authored Feb 13, 2025
1 parent e67b236 commit 3c6a104
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/action/base/create_or_insert_into_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ impl Action for CreateOrInsertIntoFile {
// that the final file goes in, so that we can rename it
// atomically
let parent_dir = path.parent().expect("File must be in a directory");
if !parent_dir.exists() {
tokio::fs::create_dir_all(&parent_dir)
.await
.map_err(|e| ActionErrorKind::CreateDirectory(parent_dir.to_owned(), e))
.map_err(Self::error)?;
}

let mut temp_file_path = parent_dir.to_owned();
{
let mut rng = rand::thread_rng();
Expand Down

0 comments on commit 3c6a104

Please sign in to comment.