From 1ead2fab0a23f75b540dc3f20e84e536f3aaa3ca Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Mon, 19 Mar 2018 22:50:18 +0200 Subject: [PATCH] Fixed index changed indicator regression caused by commit 8b8630b9 refs #7785 Change-Id: I4fc56d823f825c65c9fbece81d26d30d0cb9f16d --- .../src/org/simantics/db/indexing/DatabaseIndexing.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/DatabaseIndexing.java b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/DatabaseIndexing.java index f8a19504c..b429eb49a 100644 --- a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/DatabaseIndexing.java +++ b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/DatabaseIndexing.java @@ -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()); -- 2.47.1