From 5907307e2f83a2dc6eea6fef0028c43173758c75 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Mon, 29 May 2017 17:47:42 +0200 Subject: [PATCH] do not mark FSRecords as dirty upon opening or successful find of existing root --- .../openapi/vfs/newvfs/persistent/FSRecords.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java index 90526d716434..8439b06148bb 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java @@ -283,7 +283,9 @@ public class FSRecords { myRecords = new ResizeableMappedFile(recordsFile, 20 * 1024, storageLockContext, PagedFileStorage.BUFFER_SIZE, aligned, IOUtil.ourByteBuffersUseNativeByteOrder); - if (myRecords.length() == 0) { + boolean initial = myRecords.length() == 0; + + if (initial) { cleanRecord(0); // Clean header cleanRecord(1); // Create root record setCurrentVersion(); @@ -296,7 +298,7 @@ public class FSRecords { if (myRecords.getInt(HEADER_CONNECTION_STATUS_OFFSET) != SAFELY_CLOSED_MAGIC) { throw new IOException("FS repository wasn't safely shut down"); } - markDirty(); + if (initial) markDirty(); scanFreeRecords(); } catch (Exception e) { // IOException, IllegalArgumentException @@ -809,7 +811,6 @@ public class FSRecords { w.lock(); try { - DbConnection.markDirty(); if (ourStoreRootsSeparately) { try { try (LineNumberReader stream = new LineNumberReader(new BufferedReader(new InputStreamReader(new FileInputStream(DbConnection.myRootsFile))))) { @@ -823,6 +824,8 @@ public class FSRecords { } } } catch (FileNotFoundException ignored) {} + + DbConnection.markDirty(); try (Writer stream = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(DbConnection.myRootsFile, true)))) { int id = createRecord(); stream.write(id + " " + rootUrl + "\n"); @@ -830,7 +833,7 @@ public class FSRecords { } } - final int root = getNames().enumerate(rootUrl); + int root = getNames().tryEnumerate(rootUrl); final DataInputStream input = readAttribute(ROOT_RECORD_ID, ourChildrenAttr); int[] names = ArrayUtil.EMPTY_INT_ARRAY; @@ -860,6 +863,9 @@ public class FSRecords { } } + DbConnection.markDirty(); + root = getNames().enumerate(rootUrl); + int id; try (DataOutputStream output = writeAttribute(ROOT_RECORD_ID, ourChildrenAttr)) { id = createRecord();