From 9a46e58029df62851b3292be2b9d7fb16920a1ac Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Wed, 19 Feb 2020 17:06:26 +0200 Subject: [PATCH] imap: don't retry command on reconnection If a command fails and connection is restarted, don't try the command again; it only made sense in the previous connection's context. --- melib/src/backends/imap/connection.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/melib/src/backends/imap/connection.rs b/melib/src/backends/imap/connection.rs index 20b394378..e6a6e6020 100644 --- a/melib/src/backends/imap/connection.rs +++ b/melib/src/backends/imap/connection.rs @@ -398,13 +398,10 @@ impl ImapConnection { } else { *self.online.lock().unwrap() = (Instant::now(), Ok(())); } - let (capabilities, mut stream) = new_stream?; - let ret = action(&mut stream); - if ret.is_ok() { - self.stream = Ok(stream); - self.capabilities = capabilities; - } - ret + let (capabilities, stream) = new_stream?; + self.stream = Ok(stream); + self.capabilities = capabilities; + Err(MeliError::new("Connection timed out")) } } @@ -476,7 +473,7 @@ impl Iterator for ImapBlockingConnection { return None; } match conn.stream.as_mut().unwrap().stream.read(buf) { - Ok(0) => continue, + Ok(0) => return None, Ok(b) => { result.extend_from_slice(&buf[0..b]); debug!(unsafe { std::str::from_utf8_unchecked(result) });