From 4d4ce3e68d8d63723cd9cf6da3f2cf7c097f8332 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 5 Sep 2012 15:33:57 +0400 Subject: [PATCH] Clear dir/id cache on move --- .../vfs/newvfs/persistent/PersistentFSImpl.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java index 97b87e1c586d..076a4cff2d07 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java @@ -30,6 +30,7 @@ import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile; import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; import com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry; import com.intellij.util.ArrayUtil; +import com.intellij.util.containers.ConcurrentIntObjectMap; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.StripedLockIntObjectConcurrentHashMap; import com.intellij.util.io.ReplicatorInputStream; @@ -855,8 +856,7 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone return VfsUtilCore.toVirtualFileArray(roots); } - //guarded by dirCacheReadLock/dirCacheWriteLock - @NotNull private final StripedLockIntObjectConcurrentHashMap myIdToDirCache = new StripedLockIntObjectConcurrentHashMap(); + @NotNull private final ConcurrentIntObjectMap myIdToDirCache = new StripedLockIntObjectConcurrentHashMap(); @Override public void clearIdCache() { @@ -884,7 +884,7 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone NewVirtualFile result = doFindFile(id, cachedOnly); if (result != null && result.isDirectory()) { - NewVirtualFile old = myIdToDirCache.putIfAbsent(id, result); + NewVirtualFile old = myIdToDirCache.put(id, result); if (old != null) result = old; } return result; @@ -902,10 +902,6 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone myRootsLock.readLock().unlock(); } } - else if (parentId == id) { - LOG.error("Corrupted VFS? id=" + id + " name=" + getName(id)); - return null; - } else { NewVirtualFile parentFile = _findFileById(parentId, cachedOnly); if (parentFile == null) { @@ -1129,7 +1125,9 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone executeCreateChild(newParent, copyName); } - private static void executeMove(@NotNull VirtualFile file, @NotNull VirtualFile newParent) { + private void executeMove(@NotNull VirtualFile file, @NotNull VirtualFile newParent) { + clearIdCache(); + final int fileId = getFileId(file); final int newParentId = getFileId(newParent); final int oldParentId = getFileId(file.getParent());