Skip to content

Commit

Permalink
fs: change statSync to accessSync in realpathSync
Browse files Browse the repository at this point in the history
fs.statSync() creates and returns a heavy-weight fs.Stat object whereas
fs.accessSync() simply returns nothing.  The return value is ignored,
the call is for its side effect of throwing an ELOOP error in case of
cyclic symbolic links.

PR-URL: nodejs#4575
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
bnoordhuis authored and Michael Scovetta committed Apr 2, 2016
1 parent 15c345d commit 99ac1d7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ fs.realpathSync = function realpathSync(p, cache) {
}
}
if (linkTarget === null) {
fs.statSync(base);
fs.accessSync(base, fs.F_OK); // Throws ELOOP on cyclic links.
linkTarget = fs.readlinkSync(base);
}
resolvedLink = pathModule.resolve(previous, linkTarget);
Expand Down

0 comments on commit 99ac1d7

Please sign in to comment.