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

macOS - improve demangle to emit create events #149

Closed
wants to merge 1 commit into from

Conversation

bpasero
Copy link

@bpasero bpasero commented Sep 25, 2021

Fixes #31

The current implementation of demangle has a flaw: some operations from the macOS finder can result in the birthtime getting restored as it was (e.g. undo a delete or copy a folder). As such, nsfw often would wrongly only send a change event when it is a create event.

For some operations we can tell that the event should be create, so a boolean flag is added. The current behaviour of sending a change event is still preserved, so we might be ending up sending one event too much, but I think that is totally fine.

This slightly improves the situation for #146 in that a create event is fired for the renamed file, though we miss the delete event. I think detecting a case rename will probably be tricky for demangle because the stat check will not figure out that the old name was removed from disk.

@bpasero
Copy link
Author

bpasero commented Sep 26, 2021

Nevermind, turns out I did not fully understand how events work on macOS, specifically it looks like macOS decides to report repeated created events even when the file is modified.

To properly detect whether a file is modified or created, a different strategy is needed, such as tracking all stats of reported paths, similar to: https://github.com/parcel-bundler/watcher/blob/728b44aeec7801bae9b11e02a7fb3f0bdf94b924/src/macos/FSEventsBackend.cc#L91

@bpasero bpasero closed this Sep 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

macOS: undoing a folder delete does not report folder as added
1 participant