]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Fixed index changed indicator regression caused by commit 8b8630b9 00/1600/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 19 Mar 2018 20:50:18 +0000 (22:50 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 19 Mar 2018 20:50:18 +0000 (22:50 +0200)
refs #7785

Change-Id: I4fc56d823f825c65c9fbece81d26d30d0cb9f16d

bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/DatabaseIndexing.java

index f8a19504c8dc0165f38ddb34f27b7b31fe8a38ed..b429eb49a77d7d254be6599ced45bd39b68d3ef6 100644 (file)
@@ -12,6 +12,7 @@
 package org.simantics.db.indexing;
 
 import java.io.IOException;
 package org.simantics.db.indexing;
 
 import java.io.IOException;
+import java.nio.file.FileAlreadyExistsException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.ArrayList;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.ArrayList;
@@ -117,8 +118,12 @@ public final class DatabaseIndexing {
             // Mark change only once per DB session.
             if (getIndexChangedWriter(session).markDirty(changedFile)) {
                 Files.createDirectories(indexPath);
             // Mark change only once per DB session.
             if (getIndexChangedWriter(session).markDirty(changedFile)) {
                 Files.createDirectories(indexPath);
-                Files.createFile(changedFile);
-                FileUtils.sync(changedFile);
+                if (!Files.exists(changedFile)) {
+                    Files.createFile(changedFile);
+                    FileUtils.sync(changedFile);
+                } else if (!Files.isRegularFile(changedFile)) {
+                    throw new FileAlreadyExistsException(changedFile.toString(), null, "index dirtyness indicator file already exists but it is not a regular file");
+                }
             }
         } catch (IOException e) {
             LOGGER.error("Could not mark index changed for indexPath={} and changedFile={}", indexPath.toAbsolutePath(), changedFile.toAbsolutePath());
             }
         } catch (IOException e) {
             LOGGER.error("Could not mark index changed for indexPath={} and changedFile={}", indexPath.toAbsolutePath(), changedFile.toAbsolutePath());