Skip to content

Commit 3f70d77

Browse files
author
bcoe
committed
fs: set path when mkdir recursive called on file
PR-URL: #31607 Fixes: #28015 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent d435dc4 commit 3f70d77

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/node_file.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,7 @@ int MKDirpSync(uv_loop_t* loop,
12781278
}
12791279
break;
12801280
case UV_EACCES:
1281+
case UV_ENOTDIR:
12811282
case UV_EPERM: {
12821283
return err;
12831284
}
@@ -1356,6 +1357,7 @@ int MKDirpAsync(uv_loop_t* loop,
13561357
break;
13571358
}
13581359
case UV_EACCES:
1360+
case UV_ENOTDIR:
13591361
case UV_EPERM: {
13601362
req_wrap->continuation_data()->Done(err);
13611363
break;
@@ -1398,7 +1400,6 @@ int MKDirpAsync(uv_loop_t* loop,
13981400
}
13991401
// verify that the path pointed to is actually a directory.
14001402
if (err == 0 && !S_ISDIR(req->statbuf.st_mode)) err = UV_EEXIST;
1401-
uv_fs_req_cleanup(req);
14021403
req_wrap->continuation_data()->Done(err);
14031404
}});
14041405
if (err < 0) req_wrap->continuation_data()->Done(err);

test/parallel/test-fs-mkdir.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ function nextdir() {
148148
message: /ENOTDIR: .*mkdir/,
149149
name: 'Error',
150150
syscall: 'mkdir',
151+
path: pathname // See: https://github.com/nodejs/node/issues/28015
151152
}
152153
);
153154
}
@@ -187,6 +188,11 @@ function nextdir() {
187188
assert.strictEqual(err.code, 'ENOTDIR');
188189
assert.strictEqual(err.syscall, 'mkdir');
189190
assert.strictEqual(fs.existsSync(pathname), false);
191+
// See: https://github.com/nodejs/node/issues/28015
192+
// The path field varies slightly in Windows errors, vs., other platforms
193+
// see: https://github.com/libuv/libuv/issues/2661, for this reason we
194+
// use startsWith() rather than comparing to the full "pathname".
195+
assert(err.path.startsWith(filename));
190196
}));
191197
}
192198

0 commit comments

Comments
 (0)