-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Apply exclude filter when handling fs events. #10304
Conversation
This will prevent calls to FileSystem.resolve on excluded entries to add them to FileSystem index, thus avoiding generating fs events on these.
@dangoor, @redmunds, @peterflynn I believe this fixes an important omission in the current |
@busykai This is an important thing to fix ultimately. I know @peterflynn has thought about fixing this problem generally (see #8816) because there are a bunch of details to ultimately have file filtering handled in a consistent manner. The change you've got here makes sense to me, but I'd prefer someone who knows the filesystem better to decide about that half of the change. Also, I'd rather not see ProjectModel changes that don't include a test change. |
@dangoor, @peterflynn, I don't see any work done on the issue #8816 so far, so we can build what's needed on top of this PR or use this as a temporary workaround in case you were thinking of something radical, such as shared preferences-based excludes for both |
@busykai I agree, that we should start with this and iterate on it. If this is an improvement already, we should get it in. Since the big story is around for such a long time, I assume that it won't be addressed any time soon either. We can update the story and mention this fix specifically to keep track of already applied fixes. |
@ingorichter, good! I will add tests for |
So my concern with this is that FileSystem is supposed to guarantee that there are never two File/Directory entries representing the same path. Without putting entries in the index, that's impossible. There aren't too many places in Brackets where we actually rely on that assumption, and I'm not sure if things inside the .git folder could ever run up against any of those cases anyway... but as a generic fix this makes me a little uncomfortable. I wonder if a cleaner approach would be this model:
This would still fix the project tree bug, without violating the 'singleton' entry guarantee, and still allows using these FS APIs to read/write filtered files. I think this is also pretty easy to implement:
Note that there's still some performance overhead from .git churn because the Node native watcher sends all the events over to FileSystem before they get ignored in @zaggino @dangoor @ingorichter - Thoughts? |
@peterflynn Nice! I'm not sure if you were asking my opinion, but I think that this is a nice way to keep |
@peterflynn That seems reasonable to me |
@peterflynn, so I reverted these changes and created an integration test. your suggestion works when the changes are external. it seemingly fixes the problem with running the root cause of this is that we filter by the file's base name without checking if the parent is not watched, that is we match while one could argue whether this a bug or a feature, I suggest that we fix this by "inheriting" what you think? |
@peterflynn that sounds like a good solution. |
@busykai It sounds like you've identified two separate problems: 1)
2) File I/O done via Brackets APIs will dispatch FileSystem events for that item even if it's unwatched or filtered out.
|
For issue 2, I've realized the solution I like (no 'forced events' for filtered entries) introduces a slight pitfall. If parts of Brackets expect to always reliably get change events for its own changes, that expectation is violated if the user (or an extension) manually hands that part of Brackets a filtered-out file. For the rename case this isn't currently possible, but that's only because you can only rename things that appear in the tree; in the future, we might allow renaming directly from the working set, and you can get filtered-out items into the working set by manually picking with File > Open. One option is just to make sure no parts of Brackets have this assumption (if rename is the only case, may be easy to fix). Another option is to go with the other fix suggestion instead: just add back in the filtering double-check in the project tree code. Slight perf hit but probably negligible. |
Make sure entry is watched before handling any external change related to it.
@peterflynn, I've done quite some experimenting over the weekend and I think that for the issue 1) we need to go with "inheriting" the parent for the issue 2) it seems like if we don't cause |
}, "create a file under .git", 500); | ||
|
||
runs(function () { | ||
ProjectManager.showInTree(entry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peterflynn, this call is actually not rejected, so the test is wrong. do you have a suggestion on how to find out if the entry is in the tree? i'm thinking inspecting actual DOM, but may there's a better way.
ProjectManager.showInTree() does not reject the promise if not found.
Do not fire synthetic events if the directory is not watched.
@peterflynn, this is ready for review. |
@peterflynn, it'd be great if you could find some time to review this so we could finish it up for 1.3. |
FWIW, Intel XDK has been using this improvement (in as-is form) for 5 months now without any issues. |
Yep, this is taking far too long... |
@zaggino i do not see the .git folder in my project tree. was the git extension updated to compensate for this? |
@abose yes, try removing this code from your git extension: https://github.com/zaggino/brackets-git/blob/master/src/git/GitCli.js#L961-L978 |
I have also used the file system change events for the instant search pr- just to update the search results on project files change. #11375 Would this be safe to pull in this release. now that we know this has been in stable use for over 5 months? |
@abose: I believe it's pretty safe to merge. We didn't have any troubles having this change in Intel XDK and we rely on file watchers heavily. it would be nice, though, if @peterflynn would weigh in since he had some comments earlier. |
Thnaks @busykai . |
…-events Apply exclude filter when handling fs events.
Thank you, @abose! |
This resolves the issue with
ProjectModel
not applying exclude list when handlingFileSystem
change.This PR fixes part 2 of the issues described in #10183.EDIT:
This PR fixes #10183, see this comment for the issue definition:
FileSystem._index
when the requested entry is filtered.It might be so that 6514f20 actually draws 5d181f5 useless since no more events will be generated and the filtering will be done at
FileSystem
level, but there's no penalty on having 5d181f5 in place as well.