Skip to content

Commit

Permalink
refactor(services/azfile): Check if dir exists before create (apache#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ZutJoe committed Nov 22, 2023
1 parent 0b3505b commit 8cc1b39
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions core/src/services/azfile/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.

use std::collections::VecDeque;
use std::fmt::Debug;
use std::fmt::Formatter;
use std::fmt::Write;
Expand Down Expand Up @@ -413,15 +412,11 @@ impl AzfileCore {
}

pub async fn ensure_parent_dir_exists(&self, path: &str) -> Result<()> {
let mut dirs = VecDeque::default();
// azure file service does not support recursive directory creation
let mut p = path;
while p != "/" {
p = get_parent(p);
dirs.push_front(p);
}
for dir in dirs {
let resp = self.azfile_create_dir(dir).await?;
let resp = self.azfile_create_dir(p).await?;

if resp.status() != StatusCode::CREATED {
if resp
Expand All @@ -435,7 +430,7 @@ impl AzfileCore {
}
return Err(Error::new(
ErrorKind::Unexpected,
format!("failed to create directory: {}", dir).as_str(),
format!("failed to create directory: {}", p).as_str(),
));
}
}
Expand Down

0 comments on commit 8cc1b39

Please sign in to comment.