You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "infdahai (via GitHub)" <gi...@apache.org> on 2023/06/12 03:57:45 UTC
[GitHub] [incubator-opendal] infdahai commented on a diff in pull request #2449: feat(blocking operator): add remove_all api
infdahai commented on code in PR #2449:
URL: https://github.com/apache/incubator-opendal/pull/2449#discussion_r1226058104
##########
core/src/types/operator/blocking_operator.rs:
##########
@@ -680,6 +680,98 @@ impl BlockingOperator {
Ok(())
}
+ ///
+ /// # Notes
+ ///
+ /// We don't support batch delete now.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// # use anyhow::Result;
+ /// # use futures::io;
+ /// # use opendal::BlockingOperator;
+ /// # fn test(op: BlockingOperator) -> Result<()> {
+ /// op.remove(vec!["abc".to_string(), "def".to_string()])?;
+ /// # Ok(())
+ /// # }
+ /// ```
+ pub fn remove(&self, _paths: Vec<String>) -> Result<()> {
+ Ok(())
+ }
+
+ /// remove will remove files via the given paths.
+ ///
+ /// remove_via will remove files via the given stream.
+ ///
+ /// We will delete by chunks with given batch limit on the stream.
+ ///
+ /// # Notes
+ ///
+ /// We don't support batch delete now.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// # use anyhow::Result;
+ /// # use futures::io;
+ /// # use opendal::BlockingOperator;
+ /// # fn test(op: BlockingOperator) -> Result<()> {
+ /// # Ok(())
+ /// # }
+ /// ```
+ pub fn remove_via(&self) -> Result<()> {
+ // let stream = stream::iter(vec!["abc".to_string(), "def".to_string()]);
+ // op.remove_via(stream)?;
+ Ok(())
+ }
+
+ /// Remove the path and all nested dirs and files recursively.
+ ///
+ /// # Notes
+ ///
+ /// We don't support batch delete now.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// # use anyhow::Result;
+ /// # use futures::io;
+ /// # use opendal::BlockingOperator;
+ /// # fn test(op: BlockingOperator) -> Result<()> {
+ /// op.remove_all("path/to/dir")?;
+ /// # Ok(())
+ /// # }
+ /// ```
+ pub fn remove_all(&self, path: &str) -> Result<()> {
+ let meta = match self.stat(path) {
+ Ok(metadata) => metadata,
+
+ Err(e) if e.kind() == ErrorKind::NotFound => return Ok(()),
+
+ Err(e) => return Err(e),
+ };
+
+ if meta.mode() != EntryMode::DIR {
+ return self.delete(path);
+ }
+
+ let obs = self.scan(path)?;
+
+ obs.for_each(|v| {
+ if (match v {
+ Ok(entry) => self.inner().blocking_delete(entry.path(), OpDelete::new()),
+ Err(e) => Err(e),
Review Comment:
hi, may I ask how I should debug this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org