Add check, if source and target are the same
This commit is contained in:
parent
bf39d9a639
commit
fbf1c8ac16
|
@ -29,6 +29,9 @@ public class Move extends AbstractPlaceholderAwarePostProcessor {
|
|||
String path = fillInPlaceHolders(pathTemplate, rec);
|
||||
File src = rec.getPostProcessedFile();
|
||||
File target = new File(path, src.getName());
|
||||
if (Objects.equals(src, target)) {
|
||||
return;
|
||||
}
|
||||
LOG.info("Moving {} to {}", src.getName(), target.getParentFile().getCanonicalPath());
|
||||
Files.createParentDirs(target);
|
||||
Files.move(rec.getPostProcessedFile(), target);
|
||||
|
@ -38,7 +41,6 @@ public class Move extends AbstractPlaceholderAwarePostProcessor {
|
|||
}
|
||||
rec.getAssociatedFiles().remove(src.getCanonicalPath());
|
||||
rec.getAssociatedFiles().add(target.getCanonicalPath());
|
||||
|
||||
if (src.isFile()) {
|
||||
deleteEmptyParents(src.getParentFile());
|
||||
} else {
|
||||
|
|
|
@ -27,6 +27,9 @@ public class Rename extends AbstractPlaceholderAwarePostProcessor {
|
|||
String filename = fillInPlaceHolders(filenameTemplate, rec);
|
||||
File src = rec.getPostProcessedFile();
|
||||
File target = new File(src.getParentFile(), filename);
|
||||
if (Objects.equals(src, target)) {
|
||||
return;
|
||||
}
|
||||
LOG.info("Renaming {} to {}", src.getName(), target.getName());
|
||||
Files.move(rec.getPostProcessedFile(), target);
|
||||
rec.setPostProcessedFile(target);
|
||||
|
|
Loading…
Reference in New Issue