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);
|
String path = fillInPlaceHolders(pathTemplate, rec);
|
||||||
File src = rec.getPostProcessedFile();
|
File src = rec.getPostProcessedFile();
|
||||||
File target = new File(path, src.getName());
|
File target = new File(path, src.getName());
|
||||||
|
if (Objects.equals(src, target)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
LOG.info("Moving {} to {}", src.getName(), target.getParentFile().getCanonicalPath());
|
LOG.info("Moving {} to {}", src.getName(), target.getParentFile().getCanonicalPath());
|
||||||
Files.createParentDirs(target);
|
Files.createParentDirs(target);
|
||||||
Files.move(rec.getPostProcessedFile(), target);
|
Files.move(rec.getPostProcessedFile(), target);
|
||||||
|
@ -38,7 +41,6 @@ public class Move extends AbstractPlaceholderAwarePostProcessor {
|
||||||
}
|
}
|
||||||
rec.getAssociatedFiles().remove(src.getCanonicalPath());
|
rec.getAssociatedFiles().remove(src.getCanonicalPath());
|
||||||
rec.getAssociatedFiles().add(target.getCanonicalPath());
|
rec.getAssociatedFiles().add(target.getCanonicalPath());
|
||||||
|
|
||||||
if (src.isFile()) {
|
if (src.isFile()) {
|
||||||
deleteEmptyParents(src.getParentFile());
|
deleteEmptyParents(src.getParentFile());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,6 +27,9 @@ public class Rename extends AbstractPlaceholderAwarePostProcessor {
|
||||||
String filename = fillInPlaceHolders(filenameTemplate, rec);
|
String filename = fillInPlaceHolders(filenameTemplate, rec);
|
||||||
File src = rec.getPostProcessedFile();
|
File src = rec.getPostProcessedFile();
|
||||||
File target = new File(src.getParentFile(), filename);
|
File target = new File(src.getParentFile(), filename);
|
||||||
|
if (Objects.equals(src, target)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
LOG.info("Renaming {} to {}", src.getName(), target.getName());
|
LOG.info("Renaming {} to {}", src.getName(), target.getName());
|
||||||
Files.move(rec.getPostProcessedFile(), target);
|
Files.move(rec.getPostProcessedFile(), target);
|
||||||
rec.setPostProcessedFile(target);
|
rec.setPostProcessedFile(target);
|
||||||
|
|
Loading…
Reference in New Issue