Open matarc-zz opened 5 years ago
I did some more digging and found the problem in macOS. Basically the FSEvents API is sending a kFSEventStreamEventFlagMustScanSubDirs and it's being ignored in watcher_fsevents.go
const failure = uint32(FSEventsMustScanSubDirs | FSEventsUserDropped | FSEventsKernelDropped)
//....
if ev[i].Flags&failure != 0 {
// TODO(rjeczalik): missing error handling
continue
}
I think that at the very least we should send that Event to the User if he subscribed to it so that he knows he needs to rescan the folder in question (and its sub folders), looking at the code it's not very hard to do and I'll probably submit a patch fairly soon for it.
Ideally this wouldn't happen, but that would mean finding the bottleneck and hopefully being able to remove it, I would have to do a lot more digging for that.
Any ideas ?
Hello, First of all thanks for all the work on this library, it looks very promising!
I tried making a test program that creates many files in nested directories while a watch was set on the top level directory. My goal here was to see if notify would capture every single events.
From the results, it seems that a few events are getting dropped depending on the OS.
go version 1.11.4
This piece of code can be run using :
This will create a top folder that contains 10 nested folders, each having 1000 folders. 10 * 1000 files will be created at random places within that tree with a write on each of them and removed afterwards. I apologise for the long piece of code :
I tried running it on macOS and on a Windows 10 VM and here are the results I get (numbers vary) : macOS 10.4.2
Windows 10 VM
On macOS I seem to be able to reliably catch all remove Events, but write & create seem to fluctuate (I ran that code many times) On Windows Create and Write seem to work reliably, but remove are dropped.
Am I doing something wrong with the library or is that a bug ? Originally I only had a 1000 buffered event channel and that seemed to make me drop a few create and write events on windows, so I increased it to 1 000 000 (which seems a bit much) and it seems to behave a bit better.
There is a -keep flag option that allows you to keep the files and folders generated if you'd like to check the tree.
Hope this makes sense to you :)