fs: change statSync to accessSync in realpathSync

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: https://github.com/nodejs/node/pull/4575
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Ben Noordhuis authored and James M Snell committed 2016-01-12 12:34:44 -08:00
1 parent d8ba2c0de4
commit 809bf5e38c
1 file changed
+1 -1
+1 -1
View File
@@ -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);