Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

fs.watch false positives when watched filename starts with name of neighboring folder #25689

Closed
senritsu opened this issue Jul 16, 2015 · 0 comments

Comments

@senritsu
Copy link

Previous discussion relating to this issue can be seen in paulmillr/chokidar#296

Any changes inside a folder root/Foo/ also result in change events being fired for every file in the same folder as Foo/ whose name starts with Foo, e.g. root/foobar.js, root/foobaz.txt, etc.

The issue always appears for added or deleted files inside Foo/, and sometimes for changes to files inside Foo/. The filename of the added/changed/deleted files is irrelevant, as it seems to falsely identify the change event to the folder as a change to any file foo.**

Tests were done on windows 8.1 x64

Code to reproduce the issue:

var chokidar = require('chokidar');
var fs = require('fs');

function zerofill(i){
  return (i < 10 ? '0' : '') + i;
}

function timestamp() {
  var now = new Date();
  return '[' + zerofill(now.getHours()) + ':' + zerofill(now.getMinutes()) + ':' + zerofill(now.getSeconds()) + ']'
}

var watcher = chokidar.watch('./TestRoot/**/*');
watcher.on('change',function(file){console.log(timestamp() + ' chokidar           >>> ' + file);})

watcher = chokidar.watch('./TestRoot/**/*', {usePolling:true});
watcher.on('change',function(file){console.log(timestamp() + ' chokidar (polling) >>> ' + file);})

fs.watch('./TestRoot/', {recursive:true}, function(event, filename){
  if (event === 'change') {
    console.log(timestamp() + ' fs.watch (folder)  >>> ' + filename);
  }
});

fs.watch('./TestRoot/foobar.js', function(event, filename){
  if (event === 'change') {
    console.log(timestamp() + ' fs.watch (file)    >>> ' + filename);
  }
});
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants