]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/DatabaseIndexing.java
Fixed index changed indicator regression caused by commit 8b8630b9
[simantics/platform.git] / 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;
+import java.nio.file.FileAlreadyExistsException;
 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);
-                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());