Skip to content

Commit

Permalink
support sftp
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorgan committed Aug 14, 2024
1 parent 4b9433d commit e7daee5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/src/services/sftp/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 9 additions & 3 deletions core/src/services/sftp/lister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
Expand All @@ -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,
Expand All @@ -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())
}

0 comments on commit e7daee5

Please sign in to comment.