-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
fs.watchFile inconsistent stat return #15364
Copy link
Copy link
Closed
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
Metadata
Metadata
Assignees
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
Hi!
I encountered the following problem when using fs.watchFile. I start watching a file, let's say file1, the file is renamed into file2 and then back into file1.
On the first rename, my listener is called with currentStat filled with 0s (correct, as the file does not exist) and some values for the previousStat.
On the second rename, when the file gets the name it had initially, the previousStat is the same one as the previousStat of the first rename (I think it should be the one filled with 0s, as the file did not exist previously) and has the same modified time as the currentStat. This way, I cannot determine that the file has reappeared.
I am comparing that the modified time has changed in order to avoid false alarms triggered by file access as specified in the Node.js documentation.