diff --git a/core/src/services/sftp/backend.rs b/core/src/services/sftp/backend.rs index 637164e68964..f945c56e5dd7 100644 --- a/core/src/services/sftp/backend.rs +++ b/core/src/services/sftp/backend.rs @@ -81,7 +81,7 @@ impl Configurator for SftpConfig { /// SFTP services support. (only works on unix) /// -/// If you are interested in working on windows, pl ease refer to [this](https://github.com/apache/opendal/issues/2963) issue. +/// If you are interested in working on windows, please refer to [this](https://github.com/apache/opendal/issues/2963) issue. /// Welcome to leave your comments or make contributions. /// /// Warning: Maximum number of file holdings is depending on the remote system configuration. diff --git a/core/src/services/sftp/lister.rs b/core/src/services/sftp/lister.rs index 077e123ee396..dacda8580b3a 100644 --- a/core/src/services/sftp/lister.rs +++ b/core/src/services/sftp/lister.rs @@ -54,8 +54,14 @@ impl oio::List for SftpLister { match item { Some(e) => { - if e.filename().to_str() == Some(".") || e.filename().to_str() == Some("..") { + if e.filename().to_str() == Some("..") { continue; + } else if e.filename().to_str() == Some(".") { + let mut path = self.prefix.as_str(); + if self.prefix.is_empty() { + path = "/"; + } + return Ok(Some(Entry::new(path, e.metadata().into()))); } else { return Ok(Some(map_entry(self.prefix.as_str(), e))); } @@ -66,7 +72,7 @@ impl oio::List for SftpLister { } } -fn map_entry(prefix: &str, value: DirEntry) -> oio::Entry { +fn map_entry(prefix: &str, value: DirEntry) -> Entry { let path = format!( "{}{}{}", prefix, @@ -78,5 +84,5 @@ fn map_entry(prefix: &str, value: DirEntry) -> oio::Entry { } ); - oio::Entry::new(path.as_str(), value.metadata().into()) + Entry::new(path.as_str(), value.metadata().into()) }