doc: added note to fs.watchFile on previousStat

Explains the expected behavior of previousStat in fs.watchFile() when
a watched file disappears and reappears.

PR-URL: https://github.com/nodejs/node/pull/16099
Fixes: https://github.com/nodejs/node/issues/15364
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
NiveditN authored and Myles Borins committed 2017-11-28 13:10:26 +09:00
1 parent 229a1fa299
commit 8c070f9ed5
1 file changed
+9
+9
View File
@@ -1925,6 +1925,15 @@ you need to compare `curr.mtime` and `prev.mtime`.
`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and
`fs.unwatchFile` when possible.
*Note:* When a file being watched by `fs.watchFile()` disappears and reappears,
then the `previousStat` reported in the second callback event (the file's
reappearance) will be the same as the `previousStat` of the first callback
event (its disappearance).
This happens when:
- the file is deleted, followed by a restore
- the file is renamed twice - the second time back to its original name
## fs.write(fd, buffer[, offset[, length[, position]]], callback)
<!-- YAML
added: v0.0.2