Skip to content

Commit 57b7f40

Browse files
niknivtargos
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 6ebdd98 commit 57b7f40

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
@@ -2560,6 +2560,15 @@ v0.10.
25602560
`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and
25612561
`fs.unwatchFile` when possible.
25622562

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

0 commit comments

Comments
 (0)