emcrisostomo / fswatch

A cross-platform file change monitor with multiple backends: Apple OS X File System Events, *BSD kqueue, Solaris/Illumos File Events Notification, Linux inotify, Microsoft Windows and a stat()-based backend.
https://emcrisostomo.github.io/fswatch/
GNU General Public License v3.0
4.96k stars 327 forks source link

Implement event bubbling (was: fswatch prints all files multiple times even when they aren't changing) #255

Closed Timmmm closed 3 years ago

Timmmm commented 3 years ago
$ fswatch -r grpc
/localdata/projects/grpc/grpc
/localdata/projects/grpc/grpc
/localdata/projects/grpc/grpc
/localdata/projects/grpc/grpc
/localdata/projects/grpc/grpc
/localdata/projects/grpc/grpc
/localdata/projects/grpc/grpc
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git/branches
/localdata/projects/grpc/grpc/.git/branches
/localdata/projects/grpc/grpc/.git/branches
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git/branches
/localdata/projects/grpc/grpc/.git/branches
/localdata/projects/grpc/grpc/.git/branches
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git/branches
/localdata/projects/grpc/grpc/.git/branches
/localdata/projects/grpc/grpc/.git/branches
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git/branches
/localdata/projects/grpc/grpc/.git/branches
/localdata/projects/grpc/grpc/.git/branches
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git/hooks
/localdata/projects/grpc/grpc/.git/hooks
/localdata/projects/grpc/grpc/.git/hooks
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git/hooks
/localdata/projects/grpc/grpc/.git/hooks
/localdata/projects/grpc/grpc/.git/hooks
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git/hooks
/localdata/projects/grpc/grpc/.git/hooks
/localdata/projects/grpc/grpc/.git/hooks
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git/hooks
/localdata/projects/grpc/grpc/.git/hooks
/localdata/projects/grpc/grpc/.git/hooks
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git/info
/localdata/projects/grpc/grpc/.git/info
/localdata/projects/grpc/grpc/.git/info
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git/info
/localdata/projects/grpc/grpc/.git/info
/localdata/projects/grpc/grpc/.git/info
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git/info
/localdata/projects/grpc/grpc/.git/info
/localdata/projects/grpc/grpc/.git/info
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git/info
/localdata/projects/grpc/grpc/.git/info
/localdata/projects/grpc/grpc/.git/info
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git/logs
/localdata/projects/grpc/grpc/.git/logs
/localdata/projects/grpc/grpc/.git/logs
/localdata/projects/grpc/grpc/.git
/localdata/projects/grpc/grpc/.git/logs
/localdata/projects/grpc/grpc/.git/logs
...

It prints a new chunk of files about once per second. I didn't set up this machine but I'm pretty sure this is the filesystem:

/dev/mapper/vgsys-root on / type xfs (rw,relatime,attr2,inode64,noquota)
/dev/mapper/vgsys-root                   104833760   29314588   75519172  28% /

OS/version:

Ubuntu 18.04.3 LTS
$ fswatch --version
fswatch 1.11.2
lawik commented 3 years ago

Yeah, this was inconvenient. Moved script from Mac to an Ubuntu-ish Linux and had this behavior.

emcrisostomo commented 3 years ago

Have you tried printing event flags to see what's being reported?

lawik commented 3 years ago

No, didn't really get a good setup. Ended up with another solution entirely. So would this be read timestamp metadata or something like that?

emcrisostomo commented 3 years ago

On Linux you often get multiple different notifications for the same file, with different event flags. I'll have a look at this in case it makes sense 'bubbling events' by file name (at least for events delivered 'simultaneously'). A more sophisticated idea might be bubbling those that arrive in the same time window. But I'm not sure whether this really gives value to the users.

Opinions?

emcrisostomo commented 3 years ago

Yes, I've verified this on Linux: several different events are triggered for the same file, unlike macOS.

emcrisostomo commented 3 years ago

Fixed in master