Skip to content

Commit

Permalink
Merge pull request #2377 from Haehnchen/feature/project-dir
Browse files Browse the repository at this point in the history
ignore "Accessing invalid virtual file" errors for project root dir changes
  • Loading branch information
Haehnchen authored May 20, 2024
2 parents f1894f9 + 181470d commit 149255e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.SimpleModificationTracker;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.InvalidVirtualFileAccessException;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
Expand Down Expand Up @@ -482,8 +483,15 @@ private static Set<String> getDefaultRoutes(@NotNull Project project) {
Set<String> files = new HashSet<>();

// old "app/cache" is ignored for now
VirtualFile cache = VfsUtil.findRelativeFile(projectDir, "var", "cache");
for (VirtualFile child : cache != null ? cache.getChildren() : new VirtualFile[] {}) {
VirtualFile cache = null;

try {
cache = VfsUtil.findRelativeFile(projectDir, "var", "cache");
} catch (InvalidVirtualFileAccessException ignored) {
// "Accessing invalid virtual file"
}

for (VirtualFile child : (cache != null) ? cache.getChildren() : new VirtualFile[]{}) {
String filename = child.getName();
// support "dev" and "dev_*"
if ("dev".equals(filename) || filename.startsWith("dev_")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.SimpleModificationTracker;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.InvalidVirtualFileAccessException;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
Expand Down Expand Up @@ -124,7 +125,13 @@ private static Collection<File> getTranslationRootInner(@NotNull Project project
Set<String> caches = new HashSet<>();

for (String root : new String[] {"var/cache", "app/cache"}) {
VirtualFile cache = VfsUtil.findRelativeFile(projectDir, root.split("/"));
VirtualFile cache = null;
try {
cache = VfsUtil.findRelativeFile(projectDir, root.split("/"));
} catch (InvalidVirtualFileAccessException ignored) {
// "Accessing invalid virtual file"
}

if (cache == null) {
continue;
}
Expand Down

0 comments on commit 149255e

Please sign in to comment.