From 04c6785faecdef37b3d4eefb61c0a18ff1cbdec0 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sat, 20 Apr 2024 17:11:27 +0530 Subject: fix(ext/node): `cp` into non-existent parent directory (#23469) Fixes https://github.com/denoland/deno/issues/20604 --- ext/fs/std_fs.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ext/fs') 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) } -- cgit v1.2.3