In onopen:
onopen (er, fd) {
if (er) {
if (er.code === 'EISDIR')
this.onopen(null, null)
else if (er.code === 'ENOENT' && this.nocreate)
this.emit('done')
else
this.emit('error', er)
} else {
this.fd = fd
if (this.ref)
this.statref()
else if (!this.atime || !this.mtime)
this.fstat()
else
this.futimes()
}
}
In onfstat:
onfstat (st) {
if (typeof this.atime !== 'number')
this.atime = parseInt(st.atime.getTime()/1000, 10)
if (typeof this.mtime !== 'number')
this.mtime = parseInt(st.mtime.getTime()/1000, 10)
this.futimes()
}
If atime or mtime is missing stat is called:
else if (!this.atime || !this.mtime)
this.fstat()
In the stat callback onstat if atime is not number it is overwritten with the value returned by stat:
if (typeof this.atime !== 'number')
this.atime = parseInt(st.atime.getTime()/1000, 10)
The doc says atime should be a date not a number
atime like touch -a Can be either a Boolean, or a Date.
The doc is wrong but this causes a bug that is hard to debug.
In onopen:
In onfstat:
If atime or mtime is missing stat is called:
In the stat callback onstat if atime is not number it is overwritten with the value returned by stat:
The doc says atime should be a date not a number
The doc is wrong but this causes a bug that is hard to debug.