win,fs: uv_fs_rmdir() to return ENOENT on file (#4563)

After commit 18266a6969, it changed to return `ENOTDIR`, which makes it
consistent with other platforms but it also can be considered a breaking
change.
This commit is contained in:
Santiago Gimeno 2024-10-03 21:29:10 +02:00 committed by GitHub
parent 473dafc593
commit 88b874e63c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -1113,8 +1113,9 @@ static void fs__unlink_rmdir(uv_fs_t* req, BOOL isrmdir) {
}
if (isrmdir && !(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
/* Error if we're in rmdir mode but it is not a dir */
SET_REQ_UV_ERROR(req, UV_ENOTDIR, ERROR_DIRECTORY);
/* Error if we're in rmdir mode but it is not a dir.
* TODO: change it to UV_NOTDIR in v2. */
SET_REQ_UV_ERROR(req, UV_ENOENT, ERROR_DIRECTORY);
CloseHandle(handle);
return;
}

View File

@ -1088,6 +1088,11 @@ TEST_IMPL(fs_posix_delete) {
ASSERT_EQ(r, rmdir_req.result);
uv_fs_req_cleanup(&rmdir_req);
r = uv_fs_rmdir(NULL, &rmdir_req, "test_dir/file", NULL);
ASSERT((r == UV_ENOTDIR) || (r == UV_ENOENT));
ASSERT_EQ(r, rmdir_req.result);
uv_fs_req_cleanup(&rmdir_req);
r = uv_fs_unlink(NULL, &unlink_req, "test_dir/file", NULL);
ASSERT_OK(r);
ASSERT_OK(unlink_req.result);