FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fs: use fs.access in fs.exists by bzoz · Pull Request #18618 · nodejs/node · GitHub

/ node Public

fs: use fs.access in fs.exists - #18618

Closed
bzoz wants to merge 1 commit into
nodejs:masterfrom
JaneaSystems:bartek-exists-as-access
Closed

fs: use fs.access in fs.exists#18618
bzoz wants to merge 1 commit into
nodejs:masterfrom
JaneaSystems:bartek-exists-as-access

Conversation

bzoz commented Feb 7, 2018

Copy link
Copy Markdown
Contributor

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

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

fs

nodejs-github-bot added the fs Issues and PRs related to the fs subsystem / file system. label Feb 7, 2018

bzoz commented Feb 7, 2018

Copy link
Copy Markdown
Contributor Author

Comment thread lib/fs.js Outdated

richardlau Feb 7, 2018
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is the behavior of fs.exists altered if callback is not a function? It looks like fs.access throws a TypeError in that case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

cb is a function (it's defined on the line below) and it checks that callback is truthy.

Comment thread lib/fs.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

cb is a function (it's defined on the line below) and it checks that callback is truthy.

BridgeAR commented Feb 8, 2018

Copy link
Copy Markdown
Member

@bzoz this needs a rebase

Copy link
Copy Markdown
Contributor

I feel like we tried to do this a few years ago (sometime around the time we added fs.access{Sync} and had to revert for some reason. I'll look back and see if I can find it

bzoz commented Feb 9, 2018

Copy link
Copy Markdown
Contributor Author

@evanlucas : maybe #4679 ?

Copy link
Copy Markdown
Contributor

Oh well, I can't find it. Nevermind :]

daynin commented Feb 10, 2018

Copy link
Copy Markdown
Contributor

@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
bzoz force-pushed the bartek-exists-as-access branch from 6c9658e to cb03f5c Compare February 12, 2018 12:35

bzoz commented Feb 12, 2018

Copy link
Copy Markdown
Contributor Author

bzoz commented Feb 14, 2018

Copy link
Copy Markdown
Contributor Author

Failures look unrelated.

BridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM, just left a suggestion.

Comment thread lib/fs.js
if (ctx.errno !== undefined) {
return false;
}
fs.accessSync(path, fs.FS_OK);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

That should be picked up in a separate PR, I think.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

So, is it ok for me to land this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

BridgeAR added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Feb 16, 2018

bzoz commented Feb 22, 2018

Copy link
Copy Markdown
Contributor Author

bzoz commented Feb 22, 2018

Copy link
Copy Markdown
Contributor Author

Landed in d3955d1

bzoz closed this Feb 22, 2018
bzoz added a commit that referenced this pull request Feb 22, 2018
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>

Copy link
Copy Markdown
Contributor

Should this be backported to v9.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

bzoz added a commit to JaneaSystems/node that referenced this pull request Mar 28, 2018
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>

bzoz commented Mar 28, 2018

Copy link
Copy Markdown
Contributor Author

Backport in #19654

targos pushed a commit that referenced this pull request Apr 4, 2018
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>
targos pushed a commit that referenced this pull request Apr 4, 2018
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>
targos added backported-to-v9.x and removed author ready PRs that have at least one approval, no outstanding review comments, and a CI started. backport-requested-v9.x labels Apr 4, 2018
targos mentioned this pull request Apr 4, 2018
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
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>

Copy link
Copy Markdown
Contributor

Should this be backported to v8.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

The 9.x backport does not land cleanly unfortunately

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to the fs subsystem / file system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fs.existsSync returns wrong value on windows if there are no permissions on the given file

Back | FazBrowse Home | New Git URL