diff options
author | Wez Furlong <wez@wezfurlong.org> | 2020-01-19 08:30:39 -0800 |
---|---|---|
committer | Wez Furlong <wez@wezfurlong.org> | 2020-01-19 08:30:39 -0800 |
commit | df9a7c058c5ea6bd634067bbf623d0b57bb5f992 (patch) | |
tree | 44007c59cc947063456f1055a7e7ed8f61998efa | |
parent | 8564d28262161917bb9f8070996f97a5a87003f0 (diff) | |
download | ssh2-rs-df9a7c058c5ea6bd634067bbf623d0b57bb5f992.zip |
sftp_open yields errors via the session last error
and not the last sftp error. Confusing!
-rw-r--r-- | src/sftp.rs | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/sftp.rs b/src/sftp.rs index 025c897..25c3a74 100644 --- a/src/sftp.rs +++ b/src/sftp.rs @@ -121,13 +121,6 @@ pub enum OpenType { Dir = raw::LIBSSH2_SFTP_OPENDIR as isize, } -impl<'sftp> LockedSftp<'sftp> { - pub fn last_error(&self) -> Error { - let code = unsafe { raw::libssh2_sftp_last_error(self.raw) }; - Error::from_errno(code as c_int) - } -} - impl Sftp { pub(crate) fn from_raw_opt( raw: *mut raw::LIBSSH2_SFTP, @@ -167,7 +160,7 @@ impl Sftp { open_type as c_int, ); if ret.is_null() { - Err(locked.last_error()) + Err(locked.sess.last_error().unwrap_or_else(Error::unknown)) } else { Ok(File::from_raw(self, ret)) } |