-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs: restore javascript realpath implementation #7899
Conversation
A couple of suggestions:
|
At the last meeting, the CTC has expressed consensus with the approach in this PR: reverting, leaving the cache out, but keeping the encoding option. |
To me it looks like this reverts too many tests. Could we keep the ones that still pass? |
@ChALkeR: Those test are reverted by #7846 on which this PR depends. |
@bzoz Your call.There seems to be agreement that the long-term plan is to use a fixed libuv implementation, though, and I think keeping the binding around might be useful for e.g. comparative benchmarks.
|
bddaab2
to
0329b6a
Compare
In general this LGTM with a green CI. I definitely want to make sure this gets additional eyes on it to review, however. @nodejs/ctc |
Why does this PR also revert "fs: validate args of truncate functions in js" and "fs: make callback mandatory to all async functions" ? How are those related to the realpath problems? It makes is a lot harder to review this PR. |
Those seem to be handled by #7846, btw. |
assert(!err); | ||
assert.equal(typeof result, 'string'); | ||
assert.equal(result, filename); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don’t need the asyncCompleted
checks; wrapping the callback as common.mustCall(function(err, result) { … })
handles that automatically for you.
@bzoz Many, many thanks for starting to add regression tests! Overall LGTM, too. |
LGTM, thanks for doing the work behind this PR! |
One Windows build bot failure, running CI again to be safe: https://ci.nodejs.org/job/node-test-commit/4376/ |
I had one running here https://ci.nodejs.org/job/node-test-commit/4373/, it is green. |
Oh, sorry (but good to hear)! I’d say this is good to go once #7846 is resolved. |
28efdae
to
0c0a6b4
Compare
@misterdjules OK, squashed Commits:
|
What was the result of the discussion about the substed realpath behavior thing? This PR adds a test thus making certain behavior "correct" which might not necessarily be the case. It depends on how substed drives are interpreted, IMHO. On the maze of issues and notes I recall reading that some people where using substed drives to get shorter paths. Was that the case? What breaks if we would give them the long path? |
I've added a note to the |
LGTM, thank you. |
CI is green. Let's give it another day before landing. @nodejs/ctc @nodejs/collaborators ... please take one final look. |
@@ -1563,38 +1563,239 @@ fs.unwatchFile = function(filename, listener) { | |||
}; | |||
|
|||
|
|||
fs.realpathSync = function realpathSync(path, options) { | |||
// Regexp that finds the next partion of a (partial) path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: partion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
The benchmarks included also work for the previous JS implementation of fs.realpath(). In case the new implementation of realpath() needs to be reverted, we want these changes to stick around. PR-URL: #7899 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
The benchmarks included also work for the previous JS implementation of fs.realpath(). In case the new implementation of realpath() needs to be reverted, we want these changes to stick around. PR-URL: #7899 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
@bzoz @addaleax one thing I really liked from the behaviour of native |
@bpasero I guess you can open a separate issue for this? It sounds like something that would be okay to have. |
Make the `uv_fs_realpath()` binding (which calls the libc `realpath()` on UNIX and `GetFinalPathNameByHandle()` on Windows) available as the `fs.realpath.native()` and `fs.realpathSync.native()` functions. The binding was already available as `process.binding('fs').realpath` but was not exposed or tested - and partly broken as a result. Fixes: nodejs#8715 PR-URL: nodejs#15776 Refs: nodejs#7899 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Make the `uv_fs_realpath()` binding (which calls the libc `realpath()` on UNIX and `GetFinalPathNameByHandle()` on Windows) available as the `fs.realpath.native()` and `fs.realpathSync.native()` functions. The binding was already available as `process.binding('fs').realpath` but was not exposed or tested - and partly broken as a result. Fixes: #8715 PR-URL: #15776 Refs: #7899 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
fs
Description of change
Libuv
realpath
implementation brought a lot of problems described here #7726. This restores old JS implementation ofrealpath
andrealpathSync
, adding new API, withoptions
in place ofcache
.This requires #7846 to land, as it reverts changes to
fs
on which old JS implementation depended. This PR is about 3rd and 4th commit which bring back oldrealpath
implementation with support for the new API.First two commits are from #7846, reverting some changes to
fs
that landed after JSrealpath
implementation was dropped.Third commit reverts b488b19 bringing back JS implementation of
realpath
andrealpathSync
.Fourth commit updates old implementation. It removes the cache and implements new
realpath
API (support forencoding
parameter).This cannot land before #7846. In case #7846 does not make it, this can be easily updated.