summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWez Furlong <wez@wezfurlong.org>2020-01-19 08:30:39 -0800
committerWez Furlong <wez@wezfurlong.org>2020-01-19 08:30:39 -0800
commitdf9a7c058c5ea6bd634067bbf623d0b57bb5f992 (patch)
tree44007c59cc947063456f1055a7e7ed8f61998efa
parent8564d28262161917bb9f8070996f97a5a87003f0 (diff)
downloadssh2-rs-df9a7c058c5ea6bd634067bbf623d0b57bb5f992.zip
sftp_open yields errors via the session last error
and not the last sftp error. Confusing!
-rw-r--r--src/sftp.rs9
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))
}