Skip to content

Commit 371d1db

Browse files
niknivjoyeecheung
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 <[email protected]> Reviewed-By: Claudio Rodriguez <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 9e551ef commit 371d1db

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
@@ -2566,6 +2566,15 @@ v0.10.
25662566
`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and
25672567
`fs.unwatchFile` when possible.
25682568

2569+
*Note:* When a file being watched by `fs.watchFile()` disappears and reappears,
2570+
then the `previousStat` reported in the second callback event (the file's
2571+
reappearance) will be the same as the `previousStat` of the first callback
2572+
event (its disappearance).
2573+
2574+
This happens when:
2575+
- the file is deleted, followed by a restore
2576+
- the file is renamed twice - the second time back to its original name
2577+
25692578
## fs.write(fd, buffer[, offset[, length[, position]]], callback)
25702579
<!-- YAML
25712580
added: v0.0.2

0 commit comments

Comments
 (0)