Skip to content

Commit

Permalink
fix: Operator::remove_all behaviour on non-existing object fixed (#1587)
Browse files Browse the repository at this point in the history
  • Loading branch information
damooo authored Mar 14, 2023
1 parent aeb751d commit 725457d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/types/operator/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,16 @@ impl Operator {
/// # }
/// ```
pub async fn remove_all(&self, path: &str) -> Result<()> {
let meta = self.stat(path).await?;
let meta = match self.stat(path).await {
// If object exists.
Ok(metadata) => metadata,

// If object not found, return success.
Err(e) if e.kind() == ErrorKind::NotFound => return Ok(()),

// Pass on any other error.
Err(e) => return Err(e),
};

if meta.mode() != EntryMode::DIR {
return self.delete(path).await;
Expand Down

0 comments on commit 725457d

Please sign in to comment.