adobe/brackets — pull request #7109 by dangoor (2014-03-06 18:34:42+00:00)
Title: Fix bug with file caching

This is a fix for #7006 and #6978. @peterflynn wrote the fix and I added a test. Peter's commit has a good description of the problem:

Fix bug where file caches aren't cleared when the parent directory changes

if that directory's own parent (the file's grandparent) has changed recently:
1. Grandparent dir gets change event. Calls _clearCachedData() on all immediate children
2. File's parent dir is one of those children, so it erases its _contents
3. File's parent dir gets change event of its own.
4. Since it has no _content, it has no idea what children it has, and thus
fails to clear any of them.

The fix is to use FileIndex to find children when cached dir content is
missing.

Glenn noted we might consider simply not clearing child dirs' content (only
clear child files), but NJ pointed out we don't have any firm guarantee
that a file's parent dir is ever read before the file itself is read - so
this bug could repro in other cases. (It just so happens that JS code hints
call visitAll() very early in typical Brackets usage, but there's no
guarantee in general). So we really shouldn't ever require cached dir
content for clearing children, regardless of what grandparent change
handling does.