From: Tuukka Lehtonen Date: Mon, 19 Mar 2018 20:50:18 +0000 (+0200) Subject: Fixed index changed indicator regression caused by commit 8b8630b9 X-Git-Tag: v1.43.0~136^2~537 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=1ead2fab0a23f75b540dc3f20e84e536f3aaa3ca;p=simantics%2Fplatform.git Fixed index changed indicator regression caused by commit 8b8630b9 refs #7785 Change-Id: I4fc56d823f825c65c9fbece81d26d30d0cb9f16d --- 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());