use of org.apache.commons.io.FileExistsException in project syncany by syncany.
the class FileSystemAction method moveToConflictFile.
protected void moveToConflictFile(NormalizedPath conflictingPath) throws IOException {
if (!FileUtil.exists(conflictingPath.toFile())) {
logger.log(Level.INFO, " - Creation of conflict file not necessary. Locally conflicting file vanished from " + conflictingPath);
return;
}
int attempts = 0;
while (attempts++ < 10) {
NormalizedPath conflictedCopyPath = null;
try {
conflictedCopyPath = findConflictFilename(conflictingPath);
logger.log(Level.INFO, " - Local version conflicts, moving local file " + conflictingPath + " to " + conflictedCopyPath + " ...");
if (conflictingPath.toFile().isDirectory()) {
FileUtils.moveDirectory(conflictingPath.toFile(), conflictedCopyPath.toFile());
} else {
FileUtils.moveFile(conflictingPath.toFile(), conflictedCopyPath.toFile());
}
// Success!
break;
} catch (FileExistsException e) {
logger.log(Level.SEVERE, " - Cannot create conflict file; attempt = " + attempts + " for file: " + conflictedCopyPath, e);
} catch (FileNotFoundException e) {
logger.log(Level.INFO, " - Conflict file vanished. Don't care!", e);
} catch (Exception e) {
throw new RuntimeException("What to do here?", e);
}
}
}
Aggregations