-
Notifications
You must be signed in to change notification settings - Fork 113
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: undoing a folder delete does not report folder as added #31
Comments
Will see what I can do. I remember last time I was in this area, we saw bitmasks being reported strangely from the FSEvents API. If I recall correctly, something to do with the bitmask having multiple bits set in the callback something like:
I'd be willing to revisit to see if there's an option to avoid that junk, or even if we could come up with a better strategy for reconciling bad bitmasks. |
@implausible any chance you had a look at this? |
I think in this case none of the checks within void FSEventsService::demangle(std::string path) {
struct stat file;
if (stat(path.c_str(), &file) != 0) {
remove(path);
return;
}
if (file.st_birthtimespec.tv_sec != file.st_mtimespec.tv_sec) {
modify(path);
} else {
create(path);
}
} When I look at what fsevents does (the library chokidar uses), then I would also assume that fsevents is returning unknown event back to chokidar. In that case, chokidar also has some logic to find out if the node was added or changed (here). Chokidar probably keeps track of all the nodes it encountered during watching and then has a chance of saying if the node existed before or not. Maybe there is a better way to find out if the folder was created? It seems that when undoing the folder change, the mtime is different from the birthtime, even though the folder was just recreated. |
The demangle is definitely the most basic implementation I could think of to clarify some of the events. In GitKraken, it hasn't been a priority to get these events at the level of accuracy that is provided by the other interfaces. Improving the demangle would be a huge bonus for this library as a whole. |
I think that we could probably build a reconciliation cache for folders. If we approach it similarly to chokidar, we could keep a record of file events that we can use to demangle better. |
@implausible when I was looking into this, I was trying to understand how the native macOS APIs would not fire any event type for the undo case. In other words, are we sure there is no other event type (from the |
Possibly kFSEventStreamEventFlagItemInodeMetaMod? Regardless, there are other mangle issues that would need to be solved, not just this. You'd be surprised by the heartache in the fsevents api. |
@implausible no, from my testing this flag was not set because the Btw one thing worth mentioning is that for a fresh new folder that I create, then delete and then restore, the events work just fine. But as soon as I add a file to this folder and do the same, it does not work anymore. +1 for making |
@implausible I just had a look at fsevents and I see that they report the delete as " |
Just verified that this still happens with |
Yep, can confirm that this is the case by testing with FSEvents directly, it reports |
This still reproduces in |
Steps:
=> the watcher reports the folder as
MODIFIED
after the undo=> I would expect the folder event to be reported as
CREATED
=> I would also expect
CREATED
events for each child insideOutput:
Related issue in VS Code: microsoft/vscode#29766
The text was updated successfully, but these errors were encountered: