Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed events are not properly combined on macOS 11 #723

Closed
samschott opened this issue Dec 10, 2020 · 5 comments · Fixed by #725
Closed

Renamed events are not properly combined on macOS 11 #723

samschott opened this issue Dec 10, 2020 · 5 comments · Fixed by #725

Comments

@samschott
Copy link
Contributor

On macOS 11 and possibly previous releases, renamed events are not properly combined to a single event but are reported as separate deleted and created events instead.

The FSEventStream on macOS always reports two renamed events: one at the old path and one at the new path. Watchdog tries to combine them intelligently and relies on an undocumented observation that the event IDs of those two events will only differ by one:

# Internal moves appears to always be consecutive in the same
# buffer and have IDs differ by exactly one (while others
# don't) making it possible to pair up the two events coming
# from a singe move operation. (None of this is documented!)
# Otherwise, guess whether file was moved in or out.
# TODO: handle id wrapping
if (i + 1 < len(events) and events[i + 1].is_renamed
and events[i + 1].event_id == event.event_id + 1):
cls = DirMovedEvent if event.is_directory else FileMovedEvent

However, macOS 11, the two events will have equal event IDs. This may be the result of changes to APFS and atomic file moves.

@samschott
Copy link
Contributor Author

samschott commented Dec 10, 2020

Never mind, this issue is bogus. For some reason, the event_id for all events currently is 67584, no matter if they are related or not. I'll look into it.

@samschott
Copy link
Contributor Author

Those event IDs which Python receives are definitely strange. They are not monotonically increasing and often repeat themselves. Those surely cannot be the event IDs as documented in https://developer.apple.com/documentation/coreservices/fseventstreameventid?language=objc.

@CCP-Aporia, do you have any idea what may be going on here?

@samschott
Copy link
Contributor Author

samschott commented Dec 10, 2020

Ok, I found the issue. You have been passing event flags instead of IDs:

id = PyLong_FromLongLong(event_flags[i]);
path = PyUnicode_FromString(event_paths[i]);
flags = PyLong_FromLong(event_flags[i]);

@HEmile
Copy link

HEmile commented Dec 10, 2020

I'm having trouble handling EVENT_TYPE_MODIFIED on my macOS 10.15.6. The event doesn't fire, and afterward renaming a file, no other events fire either. Is this related?

@samschott
Copy link
Contributor Author

No, that is issue #721 which has already been fixed in the master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants