* allow Windows case-change only if filename differs

This commit is contained in:
Reinhard Pointner 2014-04-16 14:37:52 +00:00
parent 68df1b7c09
commit 3c1306ec2c
2 changed files with 3 additions and 2 deletions

View File

@ -303,7 +303,8 @@ class RenameAction extends AbstractAction {
// rename file, throw exception on failure
File source = mapping.getKey();
File destination = resolveDestination(mapping.getKey(), mapping.getValue(), false);
if (!source.getAbsolutePath().equals(destination.getAbsolutePath())) {
boolean isSameFile = source.equals(destination);
if (!isSameFile || (isSameFile && !source.getName().equals(destination.getName()))) {
action.rename(source, destination);
}

View File

@ -55,7 +55,7 @@ public final class FileUtilities {
} else {
// on Windows ATOMIC_MOVE allows us to rename files even if only lower/upper-case changes (without ATOMIC_MOVE the operation would be ignored)
try {
java.nio.file.Files.move(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
java.nio.file.Files.move(source.toPath(), destination.toPath(), StandardCopyOption.ATOMIC_MOVE);
} catch (AtomicMoveNotSupportedException e) {
java.nio.file.Files.move(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING);
}