Skip to content

Commit

Permalink
Merge branch 'main' into drop-force-tokio-rt-dep
Browse files Browse the repository at this point in the history
  • Loading branch information
tisonkun authored Jan 23, 2024
2 parents 8f67c9a + 3c4e2f1 commit d17e5d2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
14 changes: 7 additions & 7 deletions core/src/services/sftp/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl Debug for SftpBuilder {

impl SftpBuilder {
/// set endpoint for sftp backend.
/// The format is same as `openssh`, using either `[user@]hostname` or `ssh://[user@]hostname[:port]`. A username or port that is specified in the endpoint overrides the one set in the builder (but does not change the builder).
pub fn endpoint(&mut self, endpoint: &str) -> &mut Self {
self.config.endpoint = if endpoint.is_empty() {
None
Expand Down Expand Up @@ -173,10 +174,7 @@ impl Builder for SftpBuilder {
None => return Err(Error::new(ErrorKind::ConfigInvalid, "endpoint is empty")),
};

let user = match self.config.user.clone() {
Some(v) => v,
None => return Err(Error::new(ErrorKind::ConfigInvalid, "user is empty")),
};
let user = self.config.user.clone();

let root = self
.config
Expand Down Expand Up @@ -229,7 +227,7 @@ impl Builder for SftpBuilder {
pub struct SftpBackend {
endpoint: String,
root: String,
user: String,
user: Option<String>,
key: Option<String>,
known_hosts_strategy: KnownHosts,
copyable: bool,
Expand Down Expand Up @@ -500,13 +498,15 @@ impl SftpBackend {
async fn connect_sftp(
endpoint: &str,
root: String,
user: String,
user: Option<String>,
key: Option<String>,
known_hosts_strategy: KnownHosts,
) -> Result<Sftp> {
let mut session = SessionBuilder::default();

session.user(user);
if let Some(user) = user {
session.user(user);
}

if let Some(key) = &key {
session.keyfile(key);
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/sftp/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This service can be used to:

## Configuration

- `endpoint`: Set the endpoint for connection
- `endpoint`: Set the endpoint for connection. The format is same as `openssh`, using either `[user@]hostname` or `ssh://[user@]hostname[:port]`. A username or port that is specified in the endpoint overrides the one set in the builder (but does not change the builder).
- `root`: Set the work directory for backend. It uses the default directory set by the remote `sftp-server` as default
- `user`: Set the login user
- `key`: Set the public key for login
Expand Down
4 changes: 3 additions & 1 deletion website/community/news.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ title: News
sidebar_position: 2
---

- 2024-02-22: New PMC Member, Liuqing Yue [@dqhl76](https://github.com/dqhl76)
- 2024-01-23: New Committer, Yang Shuai [@hoslo](https://github.com/hoslo)
- 2024-01-22: New PMC Member, Liuqing Yue [@dqhl76](https://github.com/dqhl76)
- 2024-01-21: Apache OpenDAL [0.44.2](https://github.com/apache/opendal/releases/tag/v0.44.2) released. RM=[Zheao Li](https://github.com/Zheaoli)
- 2024-01-18: [Apache OpenDAL Graduated](https://opendal.apache.org/blog/apache-opendal-graduated)
- 2024-01-12: New Committer, Wenkang Xu [@WenyXu](https://github.com/wenyxu).
- 2024-01-06: Apache OpenDAL (incubating) 0.44.1 released. RM=Hao Ding
- 2024-01-01: New Committer, Congyi Wang.
- 2023-12-31: Apache OpenDAL (incubating) 0.44.0 released. RM=Liuqing Yue
Expand Down

0 comments on commit d17e5d2

Please sign in to comment.