Skip to content

Commit 8c070f9

Browse files
niknivMylesBorins
authored andcommitted
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: #16099 Fixes: #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>
1 parent 229a1fa commit 8c070f9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

doc/api/fs.md

+9
Original file line numberDiff line numberDiff line change
@@ -1925,6 +1925,15 @@ you need to compare `curr.mtime` and `prev.mtime`.
19251925
`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and
19261926
`fs.unwatchFile` when possible.
19271927

1928+
*Note:* When a file being watched by `fs.watchFile()` disappears and reappears,
1929+
then the `previousStat` reported in the second callback event (the file's
1930+
reappearance) will be the same as the `previousStat` of the first callback
1931+
event (its disappearance).
1932+
1933+
This happens when:
1934+
- the file is deleted, followed by a restore
1935+
- the file is renamed twice - the second time back to its original name
1936+
19281937
## fs.write(fd, buffer[, offset[, length[, position]]], callback)
19291938
<!-- YAML
19301939
added: v0.0.2

0 commit comments

Comments
 (0)