fs.lstatSync doesn't handle specific Windows REPARSE POINTS
- Version: 7.9.0
- Platform: Windows 10 (16179)
- Subsystem: fs (lstat)
Referenced issues:
- hyper #1776 - Gaze is adding all folders in HOME to watch list
- gaze #239 - fs.lstatSync doesn't handle specific Windows REPARSE POINTS
Issue
While tracking down an issue affecting hyper, it lead me to the use by gaze of fs.lstatSync.
It seems that on Windows, there is something different about the reparse point on OneDrive local sync folders, that results in a EINVAL error from fs.lstatSync. The fs.lstatSync correctly handles other junctions, folders and files in HOME with no error.
Error example - OneDrive
C:\> node
> fs.lstatSync('C:/Users/pabouwer/OneDrive')
Error: EINVAL: invalid argument, lstat 'C:\Users\pabouwer\OneDrive'
at Object.fs.lstatSync (fs.js:961:11)
at repl:1:4
at ContextifyScript.Script.runInThisContext (vm.js:23:33)
at REPLServer.defaultEval (repl.js:339:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.onLine (repl.js:536:10)
at emitOne (events.js:101:20)
at REPLServer.emit (events.js:191:7)
at REPLServer.Interface._onLine (readline.js:241:10)
C:\> junction -nobanner "C:/Users/pabouwer/OneDrive"
C:\Users\pabouwer\OneDrive: UNKNOWN MICROSOFT REPARSE POINT
Working example - My Documents
C:\> node
> fs.lstatSync('C:/Users/pabouwer/My Documents')
Stats {
dev: 2348871125,
mode: 41398,
nlink: 1,
uid: 0,
gid: 0,
rdev: 0,
blksize: undefined,
ino: 8444249301777451,
size: 27,
blocks: undefined,
atime: 2017-04-23T23:24:58.150Z,
mtime: 2017-04-23T23:24:58.150Z,
ctime: 2017-04-23T23:24:58.185Z,
birthtime: 2017-04-23T23:24:58.150Z }
C:\> junction -nobanner "C:/Users/pabouwer/My Documents"
C:\Users\pabouwer\My Documents: JUNCTION
Print Name : C:\Users\pabouwer\Documents
Substitute Name: C:\Users\pabouwer\Documents