Conversation
lib/fs.js
Outdated
There was a problem hiding this comment.
Is the behavior of fs.exists altered if callback is not a function? It looks like fs.access throws a TypeError in that case.
There was a problem hiding this comment.
cb is a function (it's defined on the line below) and it checks that callback is truthy.
lib/fs.js
Outdated
There was a problem hiding this comment.
cb is a function (it's defined on the line below) and it checks that callback is truthy.
|
@bzoz this needs a rebase |
|
I feel like we tried to do this a few years ago (sometime around the time we added |
|
@evanlucas : maybe #4679 ? |
|
Oh well, I can't find it. Nevermind :] |
|
@bzoz hi! Resolve the conflict pls |
Uses fs.access to implement fs.exists functionality. Fixes a issue, when a file exists but user does not have privileges to do stat on the file. Fixes: nodejs#17921 # Conflicts: # lib/fs.js
6c9658e to
cb03f5c
Compare
|
Rebased, PTAL. |
|
Failures look unrelated. |
BridgeAR
left a comment
There was a problem hiding this comment.
LGTM, just left a suggestion.
| if (ctx.errno !== undefined) { | ||
| return false; | ||
| } | ||
| fs.accessSync(path, fs.FS_OK); |
There was a problem hiding this comment.
I think it would be good to use a cached fs.accessSync version. That way everything would still work, even if that function gets monkey patched.
There was a problem hiding this comment.
That should be picked up in a separate PR, I think.
There was a problem hiding this comment.
Since we do not use any reference so far and now introduce one, it might break. So I would rather do that in this PR, but it's not blocking for me.
There was a problem hiding this comment.
Yeah, I get the argument but monkeypatching fs is something that already a normal pattern. If we're going to fix it for one method, I'd rather fix it for all of them so there's less inconsistency. I'm happy either way tho. I was going to get this landed but will hold off for now.
There was a problem hiding this comment.
So, is it ok for me to land this?
There was a problem hiding this comment.
It is OK to land but I personally would say it is better to use a cached version as we otherwise might introduce a potential issue that was not there before.
|
Landed in d3955d1 |
Uses fs.access to implement fs.exists functionality. Fixes a issue, when a file exists but user does not have privileges to do stat on the file. Fixes: #17921 PR-URL: #18618 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
|
Should this be backported to |
Uses fs.access to implement fs.exists functionality. Fixes a issue, when a file exists but user does not have privileges to do stat on the file. Fixes: nodejs#17921 PR-URL: nodejs#18618 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
|
Backport in #19654 |
Uses fs.access to implement fs.exists functionality. Fixes a issue, when a file exists but user does not have privileges to do stat on the file. Fixes: #17921 PR-URL: #18618 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Uses fs.access to implement fs.exists functionality. Fixes a issue, when a file exists but user does not have privileges to do stat on the file. Fixes: #17921 Backport-PR-URL: #19654 PR-URL: #18618 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Uses fs.access to implement fs.exists functionality. Fixes a issue, when a file exists but user does not have privileges to do stat on the file. Fixes: nodejs#17921 PR-URL: nodejs#18618 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
|
Should this be backported to The 9.x backport does not land cleanly unfortunately |
Uses
fs.access()to implementfs.exists()functionality. Fixes a issue, when a file exists but user does not have privileges to do stat on the file.Fixes: #17921
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
fs