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 8416a8fea9f CAMEL-20209: leverage Azure Files overwrite feature 
(#12377)
8416a8fea9f is described below

commit 8416a8fea9f57374c03832304717fe042869d285
Author: pekuz <petrku...@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 8cd7874b879..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);
     }

Reply via email to