问题
Scenario:
I am using FSEvents to monitor local watch folders successfully.
Using the same FSEVents code to monitor a directory that is within a mounted volume from a remote server over say, AFS (/Volumes/example) successfully notifies my FSEVents callback for any files the local client changes, but not changes made by other users on other machines - even though I do see those changes reflected immediately in the Finder.
Heres my FSEvents implementation: DirectoryWatcher.m
What I expect to happen:
Any updates the Finder sees, my FSEVent tooling or any other appropriate API would detect those changes and notify my app. When changes are made by any user they appear in any other users Finder, and my app would notify callbacks of changes.
What actually happens:
Client machine Bob mounts volume 'example' from Alice's server
Bob makes changes to any subdirectory within 'example', and bob's file watcher app (my app :) ) notifies immediately of changes. Yay!
Now Fred logs into Alices server and mounts the 'example' volume, and makes changes. Fred is notified - Yay. Bob is not. Boo. Also, Fred is not notified of changes that Bob makes. Boo.
Also, if Alice makes changes directly on the server, neither Fred nor Bob has FSEvents triggered - even though in all cases, the Finder immediately is aware of changes and updates file listings and icons upon any changes.
Questions:
Anyone have any pointers about notifications of file system events on remote servers? FSEvents is near perfect save for this one gotcha. Is polling the only option?
I imagine AFS/SMB protocol has notification tooling for clients that changes have occurred - but those changes are not on the file system level and this FSEVents is unaware. IE: Finder knows because it is tapped into the protocol event stream, not just the file system event stream?
Is this even possible without polling?
Note, I am testing on 10.13 through 10.11.
Thank you!
来源:https://stackoverflow.com/questions/46324539/fsevents-directory-watcher-for-remote-server-volume-only-works-for-locally-ini