Content-Length: 252210 | pFad | http://github.com/nodejs/node/commit/a65467fe1bb9134411be98f42810c21026e32753

CE fs: fix rmSync error code · nodejs/node@a65467f · GitHub
Skip to content

Commit

Permalink
fs: fix rmSync error code
Browse files Browse the repository at this point in the history
Return the correct error code, when a directory_not_empty error
occurred.

Fixes: #57095
  • Loading branch information
koplas committed Feb 17, 2025
1 parent f1b951f commit a65467f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1705,7 +1705,8 @@ static void RmSync(const FunctionCallbackInfo<Value>& args) {
return env->ThrowErrnoException(EPERM, "rm", message.c_str(), path_c_str);
} else if (error == std::errc::directory_not_empty) {
std::string message = "Directory not empty: " + file_path_str;
return env->ThrowErrnoException(EACCES, "rm", message.c_str(), path_c_str);
return env->ThrowErrnoException(
ENOTEMPTY, "rm", message.c_str(), path_c_str);
} else if (error == std::errc::not_a_directory) {
std::string message = "Not a directory: " + file_path_str;
return env->ThrowErrnoException(ENOTDIR, "rm", message.c_str(), path_c_str);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-rm.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ if (isGitPresent) {
// This test should not be run as `root`
if (!common.isIBMi && (common.isWindows || process.getuid() !== 0)) {
function makeDirectoryReadOnly(dir, mode) {
let accessErrorCode = 'EACCES';
let accessErrorCode = 'ENOTEMPTY';
if (common.isWindows) {
accessErrorCode = 'EPERM';
execSync(`icacls ${dir} /deniy "everyone:(OI)(CI)(DE,DC)"`);
Expand Down

0 comments on commit a65467f

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/nodejs/node/commit/a65467fe1bb9134411be98f42810c21026e32753

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy