CAMEL-7518: FileUtil.renameFile - should return true if file was renamed using copy/delete approach. Thanks to David R. Hoffman for reporting, and providing the solution.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4f7b3c8c Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4f7b3c8c Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4f7b3c8c Branch: refs/heads/camel-2.13.x Commit: 4f7b3c8c465c329adac7e625e49012ed3016a500 Parents: 516fe25 Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Jun 17 20:39:04 2014 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Jun 17 20:39:40 2014 +0200 ---------------------------------------------------------------------- camel-core/src/main/java/org/apache/camel/util/FileUtil.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/4f7b3c8c/camel-core/src/main/java/org/apache/camel/util/FileUtil.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/util/FileUtil.java b/camel-core/src/main/java/org/apache/camel/util/FileUtil.java index 6376c44..128c600 100644 --- a/camel-core/src/main/java/org/apache/camel/util/FileUtil.java +++ b/camel-core/src/main/java/org/apache/camel/util/FileUtil.java @@ -425,7 +425,7 @@ public final class FileUtil { if (!renamed && copyAndDeleteOnRenameFail) { // now do a copy and delete as all rename attempts failed LOG.debug("Cannot rename file from: {} to: {}, will now use a copy/delete approach instead", from, to); - renameFileUsingCopy(from, to); + renamed = renameFileUsingCopy(from, to); } if (LOG.isDebugEnabled() && count > 0) { @@ -449,18 +449,14 @@ public final class FileUtil { return false; } - boolean renamed = false; - LOG.debug("Rename file '{}' to '{}' using copy/delete strategy.", from, to); copyFile(from, to); if (!deleteFile(from)) { throw new IOException("Renaming file from '" + from + "' to '" + to + "' failed: Cannot delete file '" + from + "' after copy succeeded"); - } else { - renamed = true; } - return renamed; + return true; } public static void copyFile(File from, File to) throws IOException {