Skip to content

Commit 5ffedae

Browse files
StefanStojanovicFyko
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: nodejs#39721 PR-URL: nodejs#44536 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
1 parent b29f20d commit 5ffedae

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/fs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,7 +2600,7 @@ realpathSync.native = (path, options) => {
26002600
options = getOptions(options);
26012601
path = getValidatedPath(path);
26022602
const ctx = { path };
2603-
const result = binding.realpath(path, options.encoding, undefined, ctx);
2603+
const result = binding.realpath(pathModule.toNamespacedPath(path), options.encoding, undefined, ctx);
26042604
handleErrorFromBinding(ctx);
26052605
return result;
26062606
};
@@ -2760,7 +2760,7 @@ realpath.native = (path, options, callback) => {
27602760
path = getValidatedPath(path);
27612761
const req = new FSReqCallback();
27622762
req.oncomplete = callback;
2763-
return binding.realpath(path, options.encoding, req);
2763+
return binding.realpath(pathModule.toNamespacedPath(path), options.encoding, req);
27642764
};
27652765

27662766
/**

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

Lines 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)