yuanchuan / node-watch

A wrapper and enhancements for fs.watch
https://npm.im/node-watch
MIT License
340 stars 44 forks source link

directory watch will close after delete any file in the directory #89

Closed sysuzjz closed 4 years ago

sysuzjz commented 4 years ago

I was watching a directory, and then used admZip to generate a zip file, and it will create a cache file in the directory, then delete it after generating the real zip file. But then the watch failed. When I debuged in the source code, I found that the isClosed function return false, as it received the message whoes event type was EVENT_REMOVE. When a file is removed, the watch on the file should be removed. That is right. But it goes wrong to remove the watch on the whole directory when any file is removed.

yuanchuan commented 4 years ago

Can't reproduce it. Please provide more information: OS, node version, etc.

sysuzjz commented 4 years ago

I can't reproduce it at the lastest version. I will close the issue. Sorry for troubling.

I met the issue at version 0.5.9. Not sure if it's helpful. os: mac 10.14.4 node version: v8.11.3 When I modify a file with the path ubox/bundle_info.json, and then log in onChange callback, it logged evt: remove, name: ubox/bundle/info.json, self.isClosed(): false. I do not know how the file name changed, and then isClosed() function turns to true. Actually, the path doesn't exist, and the probability is not 100%. After I upgrade node-watch, I can't reproduce it any more. ┓( ´∀` )┏

Thanks a lot. And sorry for troubling again.