diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java index a8a40b2ebdda..e5d155076687 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java @@ -49,18 +49,22 @@ public class JarFileSystemImpl extends JarFileSystem implements ApplicationCompo private static final JarFileSystemImplLock LOCK = new JarFileSystemImplLock(); private final Set myNoCopyJarPaths; - private File myNoCopyJarDir; + private final File myNoCopyJarDir; private final Map myHandlers = ContainerUtil.newTroveMap(FileUtil.PATH_HASHING_STRATEGY); private String[] myJarPathsCache; - public JarFileSystemImpl(MessageBus bus) { + public JarFileSystemImpl(@NotNull MessageBus bus) { boolean noCopy = SystemProperties.getBooleanProperty("idea.jars.nocopy", !SystemInfo.isWindows); myNoCopyJarPaths = noCopy ? null : new ConcurrentHashSet(FileUtil.PATH_HASHING_STRATEGY); + // to prevent platform .jar files from copying + boolean runningFromDist = new File(PathManager.getLibPath(), "openapi.jar").exists(); + myNoCopyJarDir = !runningFromDist ? null : new File(PathManager.getHomePath()); + bus.connect().subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() { @Override - public void after(@NotNull final List events) { - final List rootsToRefresh = new ArrayList(); + public void after(@NotNull List events) { + List rootsToRefresh = new ArrayList(); for (VFileEvent event : events) { if (event.getFileSystem() instanceof LocalFileSystem) { @@ -87,12 +91,8 @@ public class JarFileSystemImpl extends JarFileSystem implements ApplicationCompo } if (!rootsToRefresh.isEmpty()) { - for (VirtualFile root : rootsToRefresh) { - if (root.isValid()) { - ((NewVirtualFile)root).markDirtyRecursively(); - } - } - RefreshQueue.getInstance().refresh(!ApplicationManager.getApplication().isUnitTestMode(), true, null, rootsToRefresh); + boolean async = !ApplicationManager.getApplication().isUnitTestMode(); + RefreshQueue.getInstance().refresh(async, true, null, rootsToRefresh); } } }); @@ -120,27 +120,17 @@ public class JarFileSystemImpl extends JarFileSystem implements ApplicationCompo } @Override - public void initComponent() { - // we want to prevent Platform from copying its own jars when running from dist to save system resources - final boolean isRunningFromDist = new File(PathManager.getLibPath() + File.separatorChar + "openapi.jar").exists(); - if (isRunningFromDist) { - myNoCopyJarDir = new File(new File(PathManager.getLibPath()).getParent()); - } - } + public void initComponent() { } @Override - public void disposeComponent() { - } + public void disposeComponent() { } @Override public void setNoCopyJarForPath(String pathInJar) { - if (myNoCopyJarPaths == null || pathInJar == null) { - return; - } + if (myNoCopyJarPaths == null || pathInJar == null) return; int index = pathInJar.indexOf(JAR_SEPARATOR); if (index < 0) return; - String path = pathInJar.substring(0, index); - path = path.replace('/', File.separatorChar); + String path = FileUtil.toSystemIndependentName(pathInJar.substring(0, index)); myNoCopyJarPaths.add(path); }