IDEA-150345 Invalidate Cache / Restart doesn't delete jars

This commit is contained in:
Maxim.Mossienko
2016-01-13 16:40:33 +01:00
parent 8e59641f2e
commit ef59b92a12
@@ -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();