Chokidar does `addDir` and immediately `unlinkDir` for root folder when watching drive root in Windows
Another Windows specific bug...
If I try to watch say C:\, I get addDir event for C:\ immediately followed by unlinkDir for C:\. This happens before anything else is added.
Incidentally Chokidar seems to not like C: without the slash. Is this intended?
Not sure what the unlinkDir is about. Can you show what is being emitted to the raw event when this happens? Have seen prior reports about issues trying to watch the root of C:\, but have not spent time trying to diagnose the issues. Even if some things got fixed, I wouldn't expect suitable performance trying to use chokidar to watch an entire system drive.
Is this intended?
No, it's probably fs.watch() that has an issue with it.
OK . This is strange... I am not getting any raw events before ready? I do not know what is wrong, tried different versions of Chokidar. HELP!!!!!!!!!!
I am watching with depth:1, so I guess performance is not the problem.
This is actually expected. raw events are not emitted out of the file tree scan, just the watch methods. Do you see the unlinkDir event still without any raw and prior to ready?
With Code
watcher.on('all',function(event,path){
console.log(event,':',path);
});
My first two events are:
addDir : d:\
unlinkDir : d:\
These are all before the ready event. Then everything proceeds normally... (no raw events though as you describe)...
@paulmillr it's still an issue. Happens when you start watching any root dir (C:\, D:\, etc.) on Windows. For example, if we watch C:\, after initial addDir C:\ it immediately runs unlinkDir: C:\ before getting to other dir items.
dirWatcher = chokidar
.watch(path, {
ignorePermissionErrors: true,
ignored: /(^|[\/\\])\../,
ignoreInitial: false,
depth: 0,
awaitWriteFinish: {
stabilityThreshold: 2000,
}
})
.on("all", (event, path) => {
console.log(`event: ${event}, ${path}`)
})