From bddcd06971aa3c4380b2f9899c74c1b0811755f2 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 12 Apr 2012 16:15:13 +0200 Subject: [PATCH] Fix plain roots watching on Macs --- .../openapi/vfs/impl/local/FileWatcher.java | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java index 62b8a1a7ddf5..8600cec9d6aa 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java @@ -413,15 +413,19 @@ public class FileWatcher { continue; } + final ChangeKind kind; + try { + kind = ChangeKind.valueOf(command); + } + catch (IllegalArgumentException e) { + LOG.error("Illegal watcher command: " + command); + continue; + } + synchronized (LOCK) { - final Collection watchedPaths = checkWatchable(path); + final Collection watchedPaths = checkWatchable(path, !(kind == ChangeKind.DIRTY || kind == ChangeKind.RECDIRTY)); if (!watchedPaths.isEmpty()) { - try { - onPathChange(ChangeKind.valueOf(command), watchedPaths); - } - catch (IllegalArgumentException e) { - LOG.error("Illegal watcher command: " + command); - } + onPathChange(kind, watchedPaths); } else if (LOG.isDebugEnabled()) { LOG.debug("Not watchable, filtered: " + path); @@ -489,14 +493,14 @@ public class FileWatcher { public boolean isWatched(@NotNull final VirtualFile file) { if (isOperational()) { synchronized (LOCK) { - return !checkWatchable(file.getPresentableUrl()).isEmpty(); + return !checkWatchable(file.getPresentableUrl(), true).isEmpty(); } } return false; } @NotNull - private Collection checkWatchable(final String reportedPath) { + private Collection checkWatchable(final String reportedPath, final boolean checkParent) { if (reportedPath == null) return Collections.emptyList(); myAllPaths.clear(); @@ -525,10 +529,12 @@ public class FileWatcher { myWatchedPaths.add(path); continue ext; } - final File parentFile = new File(path).getParentFile(); - if (parentFile != null && FileUtil.pathsEqual(parentFile.getPath(), root)) { - myWatchedPaths.add(path); - continue ext; + if (checkParent) { + final File parentFile = new File(path).getParentFile(); + if (parentFile != null && FileUtil.pathsEqual(parentFile.getPath(), root)) { + myWatchedPaths.add(path); + continue ext; + } } } }