Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support sftp
Browse files Browse the repository at this point in the history
meteorgan committed Aug 14, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 4b9433d commit e7daee5
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
@@ -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.
12 changes: 9 additions & 3 deletions core/src/services/sftp/lister.rs
Original file line number Diff line number Diff line change
@@ -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())
}

0 comments on commit e7daee5

Please sign in to comment.