Skip to content

Commit

Permalink
doc: added note to fs.watchFile on previousStat
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
nikniv authored and MylesBorins committed Nov 28, 2017

Unverified

The email in this signature doesn’t match the committer email.
1 parent 229a1fa commit 8c070f9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8c070f9

Please sign in to comment.