You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "meteorgan (via GitHub)" <gi...@apache.org> on 2025/03/10 17:26:38 UTC

[PR] fix(core): fix list with recursive when the object doesn't exist [opendal]

meteorgan opened a new pull request, #5732:
URL: https://github.com/apache/opendal/pull/5732

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   None
   
   # Rationale for this change
   
   when performing `list_with_recursive`, if the object doesn't exist and the underlying service does not support `list_with_recursive`, we may incorrectly return the non-existent object.
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking-changes` label.
   -->
   


-- 
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


Re: [PR] fix(core): fix list with recursive when the object doesn't exist [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #5732:
URL: https://github.com/apache/opendal/pull/5732


-- 
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


Re: [PR] fix(core): fix list with recursive when the object doesn't exist [opendal]

Posted by "meteorgan (via GitHub)" <gi...@apache.org>.
meteorgan commented on code in PR #5732:
URL: https://github.com/apache/opendal/pull/5732#discussion_r1991508981


##########
core/src/raw/oio/list/flat_list.rs:
##########
@@ -92,8 +92,20 @@ where
     async fn next(&mut self) -> Result<Option<oio::Entry>> {
         loop {
             if let Some(de) = self.next_dir.take() {
-                let (_, l) = self.acc.list(de.path(), OpList::new()).await?;
-                self.active_lister.push((Some(de), l));
+                let (_, mut l) = self.acc.list(de.path(), OpList::new()).await?;
+                if let Some(v) = l.next().await? {
+                    self.active_lister.push((Some(de.clone()), l));
+
+                    if v.mode().is_dir() {
+                        // should not loop itself again
+                        if v.path() != de.path() {
+                            self.next_dir = Some(v);
+                            continue;
+                        }
+                    } else {
+                        return Ok(Some(v));
+                    }

Review Comment:
   Generally, we could return `Ok(None)` immediately when detecting that a directory doesn't exist. However, if another thread is deleting content in related directories, we may return too early. The behavior tests caught this issue.



-- 
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


Re: [PR] fix(core): fix list with recursive when the object doesn't exist [opendal]

Posted by "meteorgan (via GitHub)" <gi...@apache.org>.
meteorgan commented on code in PR #5732:
URL: https://github.com/apache/opendal/pull/5732#discussion_r1991477402


##########
core/src/raw/oio/list/flat_list.rs:
##########
@@ -92,8 +92,20 @@ where
     async fn next(&mut self) -> Result<Option<oio::Entry>> {
         loop {
             if let Some(de) = self.next_dir.take() {
-                let (_, l) = self.acc.list(de.path(), OpList::new()).await?;
-                self.active_lister.push((Some(de), l));
+                let (_, mut l) = self.acc.list(de.path(), OpList::new()).await?;
+                if let Some(v) = l.next().await? {

Review Comment:
   Here's an interesting issue: since we include every directory that contain a subdirectory or file, if the underlying service doesn't return the directory itself in the `list` operation, we won't be able to detect it. I discovered this behavior in the `webdav` service.



-- 
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


Re: [PR] fix(core): fix list with recursive when the object doesn't exist [opendal]

Posted by "meteorgan (via GitHub)" <gi...@apache.org>.
meteorgan commented on code in PR #5732:
URL: https://github.com/apache/opendal/pull/5732#discussion_r1991483392


##########
core/src/raw/oio/list/flat_list.rs:
##########
@@ -92,8 +92,20 @@ where
     async fn next(&mut self) -> Result<Option<oio::Entry>> {
         loop {
             if let Some(de) = self.next_dir.take() {
-                let (_, l) = self.acc.list(de.path(), OpList::new()).await?;
-                self.active_lister.push((Some(de), l));
+                let (_, mut l) = self.acc.list(de.path(), OpList::new()).await?;
+                if let Some(v) = l.next().await? {

Review Comment:
   Listing an empty root path can cover this case, but we need clear the root path before testing it.



-- 
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