diff --git a/core/core/src/raw/oio/list/flat_list.rs b/core/core/src/raw/oio/list/flat_list.rs index 6689664c71ab..69ff0edb5be0 100644 --- a/core/core/src/raw/oio/list/flat_list.rs +++ b/core/core/src/raw/oio/list/flat_list.rs @@ -92,7 +92,19 @@ where async fn next(&mut self) -> Result> { loop { if let Some(de) = self.next_dir.take() { - let (_, mut l) = self.acc.list(de.path(), OpList::new()).await?; + let (_, mut l) = match self.acc.list(de.path(), OpList::new()).await { + Ok(v) => v, + Err(e) if e.kind() == ErrorKind::PermissionDenied => { + // Skip directories that we don't have permission to access + // and continue with the rest of the listing. + log::warn!( + "FlatLister skipping directory due to permission denied: {}", + de.path() + ); + continue; + } + Err(e) => return Err(e), + }; if let Some(v) = l.next().await? { self.active_lister.push((Some(de.clone()), l));