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

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 3f868ccb1 refactor(services/azfile): Check if dir exists before create 
(#3652)
3f868ccb1 is described below

commit 3f868ccb1d0c383f0dcf4ed78583b5afcf5e14dd
Author: ZutJoe <[email protected]>
AuthorDate: Thu Nov 23 12:07:35 2023 +0800

    refactor(services/azfile): Check if dir exists before create (#3652)
    
    * refactor(services/azfile): Check if dir exists before create (#3646)
    
    * perf: change the sequence of checking dir
    
    * fix: fmt code
    
    * refactor: fmt
    
    * refactor: fmt
---
 core/src/services/azfile/core.rs | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/core/src/services/azfile/core.rs b/core/src/services/azfile/core.rs
index 84fdc8a9f..2527516f5 100644
--- a/core/src/services/azfile/core.rs
+++ b/core/src/services/azfile/core.rs
@@ -420,7 +420,18 @@ impl AzfileCore {
             p = get_parent(p);
             dirs.push_front(p);
         }
-        for dir in dirs {
+
+        let mut pop_dir_count = dirs.len();
+        for dir in dirs.iter().rev() {
+            let resp = self.azfile_get_path_properties(dir).await?;
+            if resp.status() == StatusCode::NOT_FOUND {
+                pop_dir_count -= 1;
+                continue;
+            }
+            break;
+        }
+
+        for dir in dirs.iter().skip(pop_dir_count) {
             let resp = self.azfile_create_dir(dir).await?;
 
             if resp.status() != StatusCode::CREATED {

Reply via email to