You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/12/08 15:36:17 UTC

(camel) branch camel-3.x updated: CAMEL-20209: leverage Azure Files overwrite feature (#12377)

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

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


The following commit(s) were added to refs/heads/camel-3.x by this push:
     new 8b8efeb73fb CAMEL-20209: leverage Azure Files overwrite feature (#12377)
8b8efeb73fb is described below

commit 8b8efeb73fbb44b1e84b3a328b100a441f4ee914
Author: pekuz <Pe...@Eurofins.com>
AuthorDate: Fri Dec 8 16:36:10 2023 +0100

    CAMEL-20209: leverage Azure Files overwrite feature (#12377)
    
    * CAMEL-19822: must not ensure relative because target expects absolute
    
    * CAMEL-20209: leverage Azure Files feature
    
    it could be further optimized, e.g. removing the prior remove attempt but it's easier to reuse Camel base classes
---
 .../java/org/apache/camel/component/file/azure/FilesOperations.java   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesOperations.java b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesOperations.java
index da39a382ea9..6e9828742b0 100644
--- a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesOperations.java
+++ b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesOperations.java
@@ -181,8 +181,10 @@ public class FilesOperations extends NormalizedOperations {
     }
 
     private boolean renameRemote(ShareFileClient fileClient, String shareRelativeTo) {
-        // TODO set the replace flag? likely yes, callers strategy should avoid this call when otherwise 
         var options = new ShareFileRenameOptions(shareRelativeTo);
+        // known strategies try to remove an existing target file before calling rename
+        // but it is neither atomic nor sure so instruct Azure Files to overwrite the file
+        options.setReplaceIfExists(Boolean.TRUE);
         var renamed = fileClient.renameWithResponse(options, endpoint.getMetadataTimeout(), Context.NONE).getValue();
         return existsRemote(renamed);
     }