Skip to content

Commit 360b74e

Browse 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 1b16051 commit 360b74e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/fs.js

+2-2
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
/**

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

+3
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)