diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarHandler.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarHandler.java index d7c27e57f614..b089dec7a135 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarHandler.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarHandler.java @@ -246,22 +246,29 @@ public class JarHandler extends ZipHandler { private static final int VERSION = 1 + (PersistentHashMapValueStorage.COMPRESSION_ENABLED ? 15 : 0); static { - File snapshotInfoFile = new File(new File(getJarsDir()), "snapshots_info"); + File jarsDir = new File(getJarsDir()); + File snapshotInfoFile = new File(jarsDir, "snapshots_info"); int currentVersion = -1; + long currentVfsVersion = -1; File versionFile = getVersionFile(snapshotInfoFile); if (versionFile.exists()) { try { DataInputStream versionStream = new DataInputStream(new BufferedInputStream(new FileInputStream(versionFile))); try { currentVersion = DataInputOutputUtil.readINT(versionStream); + currentVfsVersion = DataInputOutputUtil.readTIME(versionStream); } finally { versionStream.close(); } } catch (IOException ignore) {} } - if (currentVersion != VERSION) { + if (currentVfsVersion != FSRecords.getCreationTimestamp()) { + FileUtil.deleteWithRenaming(jarsDir); + jarsDir.mkdirs(); + saveVersion(versionFile); + } else if (currentVersion != VERSION) { PersistentHashMap.deleteFilesStartingWith(snapshotInfoFile); saveVersion(versionFile); } @@ -275,13 +282,13 @@ public class JarHandler extends ZipHandler { @Override public void save(@NotNull DataOutput out, CacheLibraryInfo value) throws IOException { IOUtil.writeUTF(out, value.mySnapshotPath); - out.writeLong(value.myModificationTime); - out.writeLong(value.myFileLength); + DataInputOutputUtil.writeTIME(out, value.myModificationTime); + DataInputOutputUtil.writeLONG(out, value.myFileLength); } @Override public CacheLibraryInfo read(@NotNull DataInput in) throws IOException { - return new CacheLibraryInfo(IOUtil.readUTF(in), in.readLong(), in.readLong()); + return new CacheLibraryInfo(IOUtil.readUTF(in), DataInputOutputUtil.readTIME(in), DataInputOutputUtil.readLONG(in)); } } ); @@ -391,6 +398,7 @@ public class JarHandler extends ZipHandler { DataOutputStream versionOutputStream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(versionFile))); try { DataInputOutputUtil.writeINT(versionOutputStream, VERSION); + DataInputOutputUtil.writeTIME(versionOutputStream, FSRecords.getCreationTimestamp()); } finally { versionOutputStream.close();