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
5.04k stars 328 forks source link

PlatformSpecific instead of Updated on Darwin 19.4 #243

Closed thoni56 closed 3 years ago

thoni56 commented 4 years ago

I suddenly felt I didn't get the behaviour from some scripts I had when running on Darwin/MacOS. Investigation showed that

$ fswatch . --event-flags

and then touching an existing file ´x´ gave the following output

/private/tmp/utman-test/x PlatformSpecific IsFile

I was expecting ... Updated isFile or something.

However touching a non-existing file gave the expected output

/private/tmp/utman-test/zz Created IsFile

I suppose the underlying fsevents or Darwin has changed somehow.

This happend (I think) after upgrading MacOS/Darwing to 10.15.4 (19E287).

c960657 commented 4 years ago

On my MacOS 10.15.4, touch foo.txt returns kFSEventStreamEventFlagItemIsFile | kFSEventStreamEventFlagItemInodeMetaMod.

kFSEventStreamEventFlagItemInodeMetaMod is mapped to PlatformSpecific.

I would it make sense to map it to AttributeModified instead?

steamfire commented 4 years ago

From issue #62 :

I have observed this behaviour and I think it's due to the FSEvents API buffering and bubbling events by path I'm closing this issue because it is an effect or the FSEvents behaviour.

That buffering/bubbling explanation doesn't make sense based on behavior I see. See below. I created a file using 'touch testfswatch6.txt'. I then simply repeated this 'touch testfswatch6.txt' command multiple times.

The output from fswatch for the sequence of touches proceeds through this sequence of event flags, while issuing the same command repeatedly (with a few seconds between repeats):

Created 
PlatformSpecific 
Created PlatformSpecific
PlatformSpecific
PlatformSpecific 
PlatformSpecific
PlatformSpecific 

It doesn't make sense for it to report Created twice, does it?

Here is what I issued for commands, and their timestamps, to interact with a specific file.

13:17:26 $ touch testfswatch6.txt
13:17:36 $ touch testfswatch6.txt
13:17:49 $ touch testfswatch6.txt
13:18:39 $ touch testfswatch6.txt
13:18:56 $ touch testfswatch6.txt
13:18:58 $ touch testfswatch6.txt
13:19:02 $ rm testfswatch6.txt 

Here are the results of fswatch, with timestamps:

$ fswatch . --event-flags --timestamp
Mon Jul  6 13:17:36 2020 /testfswatch6.txt Created IsFile
Mon Jul  6 13:17:36 2020 /testfswatch6.txt PlatformSpecific IsFile
Mon Jul  6 13:17:43 2020  PlatformSpecific OwnerModified AttributeModified IsDir
Mon Jul  6 13:17:49 2020 /testfswatch6.txt Created PlatformSpecific IsFile
Mon Jul  6 13:18:40 2020 /testfswatch6.txt PlatformSpecific IsFile
Mon Jul  6 13:18:57 2020 /testfswatch6.txt PlatformSpecific IsFile
Mon Jul  6 13:18:58 2020 /testfswatch6.txt PlatformSpecific IsFile
Mon Jul  6 13:19:02 2020 /testfswatch6.txt PlatformSpecific IsFile
Mon Jul  6 13:19:07 2020 /testfswatch6.txt Removed PlatformSpecific IsFile
Mon Jul  6 13:19:13 2020  PlatformSpecific OwnerModified AttributeModified IsDir

On OSX 10.13.6, fswatch 1.14.0

emcrisostomo commented 3 years ago

Fixed in master, I'll roll out a release soon