do not mark FSRecords as dirty upon opening or successful find of

existing root
This commit is contained in:
Maxim.Mossienko
2017-05-29 17:57:31 +02:00
parent e2aca58335
commit 5907307e2f
@@ -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();