ChildInfo (@NotNull VirtualFile parent, @NotNull String childName, @NotNull NewVirtualFileSystem fs) { int parentId = getFileId(parent); Ref<ChildInfo> result = new Ref<>(); Function<ListResult, ListResult> convertor = children -> { ChildInfo child = findExistingChildInfo(parent, childName, children.children); if (child != null) { result.set(child); return children; } //MAYBE RC: why do we access FS on lookup? maybe it is better to look only VFS, and issue // refresh request if children is not loaded -- and rely on automatic refresh to // update VFS if actual FS children are changed? This way here we'll have read-only scan // without concurrent modification problems Pair<@NotNull FileAttributes, String> childData = getChildData(fs, parent, childName, null, null); // todo: use BatchingFileSystem if (childData == null) { return children; } String canonicalName; if (parent.isCaseSensitive()) { canonicalName = childName; } else { canonicalName = fs.getCanonicallyCasedName(new FakeVirtualFile(parent, childName)); if (Strings.isEmptyOrSpaces(canonicalName)) { return children; } if (!childName.equals(canonicalName)) { child = findExistingChildInfo(parent, canonicalName, children.children); result.set(child); } } if (child == null) { if (result.isNull()) { child = makeChildRecord(parent, parentId, canonicalName, childData, fs, null); result.set(child); } else { // might have stored on a previous attempt child = result.get(); } return children.insert(child); } return children; }; vfsPeer.update(parent, parentId, convertor); return result.get(); }