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;
// 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());