From 9fde5cb5e045551fe344b3f60370744eea30ccb4 Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Thu, 17 Oct 2024 12:51:15 -0700 Subject: fix(node/fs): copyFile with `COPYFILE_EXCL` should not throw if the destination doesn't exist (#26360) Fixes #26313. We were checking for the NotFound error, but still calling the callback with the error / throwing. --- ext/node/polyfills/_fs/_fs_copy.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ext/node/polyfills/_fs/_fs_copy.ts') diff --git a/ext/node/polyfills/_fs/_fs_copy.ts b/ext/node/polyfills/_fs/_fs_copy.ts index 2f8ddf4fc..0434bff4d 100644 --- a/ext/node/polyfills/_fs/_fs_copy.ts +++ b/ext/node/polyfills/_fs/_fs_copy.ts @@ -53,8 +53,9 @@ export function copyFile( }, (e) => { if (e instanceof Deno.errors.NotFound) { Deno.copyFile(srcStr, destStr).then(() => cb(null), cb); + } else { + cb(e); } - cb(e); }); } else { Deno.copyFile(srcStr, destStr).then(() => cb(null), cb); @@ -83,8 +84,9 @@ export function copyFileSync( } catch (e) { if (e instanceof Deno.errors.NotFound) { Deno.copyFileSync(srcStr, destStr); + } else { + throw e; } - throw e; } } else { Deno.copyFileSync(srcStr, destStr); -- cgit v1.2.3