mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
fs: move rmSync
implementation to c++
PR-URL: https://github.com/nodejs/node/pull/53617 Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
parent
cafd44dc7e
commit
7168295e7a
6 changed files with 114 additions and 177 deletions
13
lib/fs.js
13
lib/fs.js
|
@ -161,7 +161,6 @@ let promises = null;
|
|||
let ReadStream;
|
||||
let WriteStream;
|
||||
let rimraf;
|
||||
let rimrafSync;
|
||||
let kResistStopPropagation;
|
||||
|
||||
// These have to be separate because of how graceful-fs happens to do it's
|
||||
|
@ -1124,7 +1123,7 @@ function lazyLoadCp() {
|
|||
|
||||
function lazyLoadRimraf() {
|
||||
if (rimraf === undefined)
|
||||
({ rimraf, rimrafSync } = require('internal/fs/rimraf'));
|
||||
({ rimraf } = require('internal/fs/rimraf'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1192,8 +1191,7 @@ function rmdirSync(path, options) {
|
|||
emitRecursiveRmdirWarning();
|
||||
options = validateRmOptionsSync(path, { ...options, force: false }, true);
|
||||
if (options !== false) {
|
||||
lazyLoadRimraf();
|
||||
return rimrafSync(path, options);
|
||||
return binding.rmSync(path, options.maxRetries, options.recursive, options.retryDelay);
|
||||
}
|
||||
} else {
|
||||
validateRmdirOptions(options);
|
||||
|
@ -1244,11 +1242,8 @@ function rm(path, options, callback) {
|
|||
* @returns {void}
|
||||
*/
|
||||
function rmSync(path, options) {
|
||||
lazyLoadRimraf();
|
||||
return rimrafSync(
|
||||
getValidatedPath(path),
|
||||
validateRmOptionsSync(path, options, false),
|
||||
);
|
||||
const opts = validateRmOptionsSync(path, options, false);
|
||||
return binding.rmSync(getValidatedPath(path), opts.maxRetries, opts.recursive, opts.retryDelay);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue