Skip to content

Commit 3c6a104

Browse files
authored
CreateOrInsertIntoFile: create parent dir if nonexistent (#1434)
1 parent e67b236 commit 3c6a104

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/action/base/create_or_insert_into_file.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ impl Action for CreateOrInsertIntoFile {
203203
// that the final file goes in, so that we can rename it
204204
// atomically
205205
let parent_dir = path.parent().expect("File must be in a directory");
206+
if !parent_dir.exists() {
207+
tokio::fs::create_dir_all(&parent_dir)
208+
.await
209+
.map_err(|e| ActionErrorKind::CreateDirectory(parent_dir.to_owned(), e))
210+
.map_err(Self::error)?;
211+
}
212+
206213
let mut temp_file_path = parent_dir.to_owned();
207214
{
208215
let mut rng = rand::thread_rng();

0 commit comments

Comments
 (0)