diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2024-04-20 17:11:27 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-20 11:41:27 +0000 |
commit | 04c6785faecdef37b3d4eefb61c0a18ff1cbdec0 (patch) | |
tree | 12f4daf9b599cb0de8378673f0a37a14fe4c209d /ext/fs | |
parent | e0554ac4a2da95ad98eef36246283cb8f38a3afe (diff) |
fix(ext/node): `cp` into non-existent parent directory (#23469)
Fixes https://github.com/denoland/deno/issues/20604
Diffstat (limited to 'ext/fs')
-rw-r--r-- | ext/fs/std_fs.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/fs/std_fs.rs b/ext/fs/std_fs.rs index 1176697de..6bc15a72d 100644 --- a/ext/fs/std_fs.rs +++ b/ext/fs/std_fs.rs @@ -576,6 +576,12 @@ fn cp(from: &Path, to: &Path) -> FsResult<()> { ); } } + + // Ensure parent destination directory exists + if let Some(parent) = to.parent() { + fs::create_dir_all(parent)?; + } + copy_file(from, to) } |