- if (indexPath.mkdirs()) {
- if (changedFile.createNewFile()) {
- FileUtils.syncFile(changedFile);
- }
+ Files.createDirectories(indexPath);
+ 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");