Skip to content

Commit

Permalink
feat: remove_via can delete files concurrently
Browse files Browse the repository at this point in the history
Signed-off-by: Wenyu Huang <[email protected]>
  • Loading branch information
uran0sH committed Mar 7, 2023
1 parent a3c7b33 commit 8891586
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/types/operator/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ impl Operator {
/// # Ok(())
/// # }
/// ```
pub async fn remove_via(&self, mut input: impl Stream<Item = String> + Unpin) -> Result<()> {
pub async fn remove_via(&self, input: impl Stream<Item = String> + Unpin) -> Result<()> {
if self.info().can_batch() {
let mut input = input.map(|v| (v, OpDelete::default())).chunks(self.limit());

Expand All @@ -704,9 +704,13 @@ impl Operator {
}
}
} else {
while let Some(path) = input.next().await {
self.inner().delete(&path, OpDelete::default()).await?;
}
input
.map(Ok)
.try_for_each_concurrent(self.limit, |path| async move {
let _ = self.inner().delete(&path, OpDelete::default()).await?;
Ok::<(), Error>(())
})
.await?;
}

Ok(())
Expand Down

0 comments on commit 8891586

Please sign in to comment.