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: nodejs#57095
  • Loading branch information
koplas committed Feb 17, 2025
1 parent f1b951f commit 1b4a151
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1705,7 +1705,7 @@ 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

0 comments on commit 1b4a151

Please sign in to comment.