mirror of https://github.com/nodejs/node.git
fs: refactor rimraf to avoid using primordials
PR-URL: https://github.com/nodejs/node/pull/54834 Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>pull/54879/head
parent
2ef33af16e
commit
741004a3b8
|
@ -7,7 +7,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeForEach,
|
|
||||||
Promise,
|
Promise,
|
||||||
SafeSet,
|
SafeSet,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
@ -132,8 +131,10 @@ function _rmchildren(path, options, callback) {
|
||||||
|
|
||||||
let done = false;
|
let done = false;
|
||||||
|
|
||||||
ArrayPrototypeForEach(files, (child) => {
|
const childPathPrefix = Buffer.concat([pathBuf, separator]);
|
||||||
const childPath = Buffer.concat([pathBuf, separator, child]);
|
|
||||||
|
for (let i = 0; i < files.length; i++) {
|
||||||
|
const childPath = Buffer.concat([childPathPrefix, files[i]]);
|
||||||
|
|
||||||
rimraf(childPath, options, (err) => {
|
rimraf(childPath, options, (err) => {
|
||||||
if (done)
|
if (done)
|
||||||
|
@ -148,7 +149,7 @@ function _rmchildren(path, options, callback) {
|
||||||
if (numFiles === 0)
|
if (numFiles === 0)
|
||||||
rmdir(path, callback);
|
rmdir(path, callback);
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue