Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNitzan Uziely <linkgoron@gmail.com>2021-05-14 02:26:20 +0300
committerJames M Snell <jasnell@gmail.com>2021-05-25 17:18:05 +0300
commitf9447b71a6b458adbb265f8a5fd38ebf41bc97a4 (patch)
tree17532057b74f3c3f73f568cca2e995d7dadcffad /lib
parentfa7cdd6fc9dffa8139f9350f54959b01bf7a1151 (diff)
fs: fix rmsync error swallowing
fix rmsync swallowing errors instead of throwing them. fixes: https://github.com/nodejs/node/issues/38683 fixes: https://github.com/nodejs/node/issues/34580 PR-URL: https://github.com/nodejs/node/pull/38684 Fixes: https://github.com/nodejs/node/issues/38683 Fixes: https://github.com/nodejs/node/issues/34580 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/fs/rimraf.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/internal/fs/rimraf.js b/lib/internal/fs/rimraf.js
index 675c2448c45..84f32dc6bb9 100644
--- a/lib/internal/fs/rimraf.js
+++ b/lib/internal/fs/rimraf.js
@@ -219,6 +219,11 @@ function _unlinkSync(path, options) {
i < tries &&
options.retryDelay > 0) {
sleep(i * options.retryDelay);
+ } else if (err.code === 'ENOENT') {
+ // The file is already gone.
+ return;
+ } else if (i === tries) {
+ throw err;
}
}
}
@@ -231,8 +236,9 @@ function _rmdirSync(path, options, originalErr) {
} catch (err) {
if (err.code === 'ENOENT')
return;
- if (err.code === 'ENOTDIR')
- throw originalErr;
+ if (err.code === 'ENOTDIR') {
+ throw originalErr || err;
+ }
if (notEmptyErrorCodes.has(err.code)) {
// Removing failed. Try removing all children and then retrying the
@@ -259,10 +265,17 @@ function _rmdirSync(path, options, originalErr) {
i < tries &&
options.retryDelay > 0) {
sleep(i * options.retryDelay);
+ } else if (err.code === 'ENOENT') {
+ // The file is already gone.
+ return;
+ } else if (i === tries) {
+ throw err;
}
}
}
}
+
+ throw originalErr || err;
}
}