Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2d87b6f

Browse filesBrowse files
StefanStojanovicRafaelGSS
authored andcommitted
win: fix fs.realpath.native for long paths
Unlike other fs.js functions that work with paths, realpath.native isn't using pathModule.toNamespacedPath prior to calling libuv function. This is causing issues on windows. Windows long path test is also improved to cover the mentioned issue. Fixes: #39721 PR-URL: #44536 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
1 parent 8b256a3 commit 2d87b6f
Copy full SHA for 2d87b6f

File tree

Expand file treeCollapse file tree

2 files changed

+5
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-2
lines changed
Open diff view settings
Collapse file

‎lib/fs.js‎

Copy file name to clipboardExpand all lines: lib/fs.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,7 +2612,7 @@ realpathSync.native = (path, options) => {
26122612
options = getOptions(options);
26132613
path = getValidatedPath(path);
26142614
const ctx = { path };
2615-
const result = binding.realpath(path, options.encoding, undefined, ctx);
2615+
const result = binding.realpath(pathModule.toNamespacedPath(path), options.encoding, undefined, ctx);
26162616
handleErrorFromBinding(ctx);
26172617
return result;
26182618
};
@@ -2772,7 +2772,7 @@ realpath.native = (path, options, callback) => {
27722772
path = getValidatedPath(path);
27732773
const req = new FSReqCallback();
27742774
req.oncomplete = callback;
2775-
return binding.realpath(path, options.encoding, req);
2775+
return binding.realpath(pathModule.toNamespacedPath(path), options.encoding, req);
27762776
};
27772777

27782778
/**
Collapse file

‎test/parallel/test-fs-long-path.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-long-path.js
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,7 @@ console.log({
4343

4444
fs.writeFile(fullPath, 'ok', common.mustSucceed(() => {
4545
fs.stat(fullPath, common.mustSucceed());
46+
47+
// Tests https://github.com/nodejs/node/issues/39721
48+
fs.realpath.native(fullPath, common.mustSucceed());
4649
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.