This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 7a3edcd  CAMEL-16657: camel-ftp - fileExists=Append should check for 
file exists as append only works on some ftp servers if a file already exists.
7a3edcd is described below

commit 7a3edcd3d69a510153e3cf71b2fa3d844d93e23d
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Tue May 25 17:58:09 2021 +0200

    CAMEL-16657: camel-ftp - fileExists=Append should check for file exists as 
append only works on some ftp servers if a file already exists.
---
 .../java/org/apache/camel/component/file/remote/FtpOperations.java | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
index f92a747..ea8a593 100644
--- 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
+++ 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
@@ -706,10 +706,11 @@ public class FtpOperations implements 
RemoteFileOperations<FTPFile> {
     private boolean doStoreFile(String name, String targetName, Exchange 
exchange) throws GenericFileOperationFailedException {
         log.trace("doStoreFile({})", targetName);
 
+        boolean existFile = false;
         // if an existing file already exists what should we do?
         if (endpoint.getFileExist() == GenericFileExist.Ignore || 
endpoint.getFileExist() == GenericFileExist.Fail
-                || endpoint.getFileExist() == GenericFileExist.Move) {
-            boolean existFile = existsFile(targetName);
+                || endpoint.getFileExist() == GenericFileExist.Move || 
endpoint.getFileExist() == GenericFileExist.Append) {
+            existFile = existsFile(targetName);
             if (existFile && endpoint.getFileExist() == 
GenericFileExist.Ignore) {
                 // ignore but indicate that the file was written
                 log.trace("An existing file already exists: {}. Ignore and do 
not override it.", name);
@@ -749,7 +750,7 @@ public class FtpOperations implements 
RemoteFileOperations<FTPFile> {
             final StopWatch watch = new StopWatch();
             boolean answer;
             log.debug("About to store file: {} using stream: {}", targetName, 
is);
-            if (endpoint.getFileExist() == GenericFileExist.Append) {
+            if (existFile && endpoint.getFileExist() == 
GenericFileExist.Append) {
                 log.trace("Client appendFile: {}", targetName);
                 answer = client.appendFile(targetName, is);
             } else {

Reply via email to