From df062d2c788fd76546d59c67452d8d0fe569c533 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 5 Jan 2024 18:28:33 +0530 Subject: fix(ext/node): add fs.cp, fs.cpSync, promises.cp (#21745) Fixes https://github.com/denoland/deno/issues/20803 Fixes https://github.com/denoland/deno/issues/21723 Performance: copying a 48GiB rust `target` folder (recursive) | Platform | `deno` | `node v21.5` | Improvement | | -------- | ------- | ------- | ------- | | macOS (APFS) | 3.1secs | 127.99 secs | **42x** | | Windows | 18.3secs | 67.2secs | **3.8x** | Copying files with varying sizes: ![image](https://github.com/denoland/deno/assets/34997667/58932652-6f7a-47f5-8504-896dc9ab4ddc) --- cli/standalone/file_system.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cli/standalone/file_system.rs') diff --git a/cli/standalone/file_system.rs b/cli/standalone/file_system.rs index 69e95a97f..f1ea570b5 100644 --- a/cli/standalone/file_system.rs +++ b/cli/standalone/file_system.rs @@ -175,6 +175,17 @@ impl FileSystem for DenoCompileFileSystem { } } + fn cp_sync(&self, from: &Path, to: &Path) -> FsResult<()> { + self.error_if_in_vfs(to)?; + + RealFs.cp_sync(from, to) + } + async fn cp_async(&self, from: PathBuf, to: PathBuf) -> FsResult<()> { + self.error_if_in_vfs(&to)?; + + RealFs.cp_async(from, to).await + } + fn stat_sync(&self, path: &Path) -> FsResult { if self.0.is_path_within(path) { Ok(self.0.stat(path)?) -- cgit v1.2.3