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

macosX inconsistent event reporting for options -x and -o #233

Open UNIVAC-Colonel-Panic opened 5 years ago

UNIVAC-Colonel-Panic commented 5 years ago

fswatch v1.14.0 on macosX 10.11.6 (El Capitan)

I've read the different reported issues (e.g., #144, #62) where creating a new file sometimes simultaneously reports Created and Removed events when running with -x option. I did some experimenting and have discovered that the -o option seems to consistently (correctly) report only one event.

If the issue is as described in the other issues:

OS X may return event flags of previous events for the same file if they occur sufficiently close in time.

then wouldn't -x and -o be consistent, either both reporting two events or both reporting a single event?

Steps to duplicate

Terminal session 1:

Assuming that 10 seconds is not "sufficiently close in time."

while :; do touch x; sleep 10; rm x; sleep 10; done

Terminal session 2:

Test 1 that consistently outputs a "1" for number of events. fswatch --event Created --event Removed -o x

Test 2 that sometimes shows Created Removed and sometimes shows Removed.

fswatch --event Created --event Removed -x -t x

Sample output

Test 1
    $ time fswatch --event Created --event  Removed  -o -t x
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    ^C
    real    5m47.744s
    user    0m0.010s
    sys     0m0.011s
Test 2
    $ time fswatch --event Created --event  Removed  -x -t x
    Wed Sep 18 15:22:25 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:22:35 2019 /Users/taa/x Removed
    Wed Sep 18 15:22:44 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:22:54 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:23:05 2019 /Users/taa/x Created
    Wed Sep 18 15:23:16 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:23:24 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:23:36 2019 /Users/taa/x Removed
    Wed Sep 18 15:23:46 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:23:56 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:24:06 2019 /Users/taa/x Created
    Wed Sep 18 15:24:16 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:24:26 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:24:36 2019 /Users/taa/x Removed
    Wed Sep 18 15:24:45 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:24:56 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:25:06 2019 /Users/taa/x Created
    Wed Sep 18 15:25:16 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:25:26 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:25:36 2019 /Users/taa/x Removed
    Wed Sep 18 15:25:45 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:25:56 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:26:06 2019 /Users/taa/x Created
    Wed Sep 18 15:26:16 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:26:26 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:26:36 2019 /Users/taa/x Removed
    Wed Sep 18 15:26:46 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:26:55 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:27:06 2019 /Users/taa/x Created
    Wed Sep 18 15:27:16 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:27:26 2019 /Users/taa/x Created Removed
    Wed Sep 18 15:27:36 2019 /Users/taa/x Removed
    Wed Sep 18 15:27:46 2019 /Users/taa/x Created Removed
    ^C
    real    5m28.767s
    user    0m0.011s
    sys     0m0.011s
steamfire commented 4 years ago

Same here. fswatch version 1.14.0 macos 10.13.6