From eece5b9ac8f95f8b1d28a88906e27584355e986a Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sun, 15 Dec 2019 01:40:39 +0100 Subject: [PATCH] fix idle_wait.await result processing --- src/imap/idle.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/imap/idle.rs b/src/imap/idle.rs index 38b546434..1c4ad7a0c 100644 --- a/src/imap/idle.rs +++ b/src/imap/idle.rs @@ -21,6 +21,9 @@ pub enum Error { #[fail(display = "IMAP IDLE protocol timed out")] IdleTimeout(#[cause] async_std::future::TimeoutError), + #[fail(display = "IMAP IDLE protocol timed out")] + IdleError(#[cause] async_imap::error::Error), + #[fail(display = "IMAP server does not have IDLE capability")] IdleAbilityMissing, @@ -80,18 +83,22 @@ impl Imap { } else { info!(context, "Idle entering wait-on-remote state"); match idle_wait.await { - IdleResponse::NewData(_) => { + Ok(IdleResponse::NewData(_)) => { info!(context, "Idle has NewData"); } // TODO: idle_wait does not distinguish manual interrupts // from Timeouts if we would know it's a Timeout we could bail // directly and reconnect . - IdleResponse::Timeout => { + Ok(IdleResponse::Timeout) => { info!(context, "Idle-wait timeout or interruption"); } - IdleResponse::ManualInterrupt => { + Ok(IdleResponse::ManualInterrupt) => { info!(context, "Idle wait was interrupted"); } + Err(err) => { + self.trigger_reconnect(); + return Err(Error::IdleError(err)); + } } } // if we can't properly terminate the idle @@ -134,18 +141,22 @@ impl Imap { } else { info!(context, "Idle entering wait-on-remote state"); match idle_wait.await { - IdleResponse::NewData(_) => { + Ok(IdleResponse::NewData(_)) => { info!(context, "Idle has NewData"); } // TODO: idle_wait does not distinguish manual interrupts // from Timeouts if we would know it's a Timeout we could bail // directly and reconnect . - IdleResponse::Timeout => { + Ok(IdleResponse::Timeout) => { info!(context, "Idle-wait timeout or interruption"); } - IdleResponse::ManualInterrupt => { + Ok(IdleResponse::ManualInterrupt) => { info!(context, "Idle wait was interrupted"); } + Err(err) => { + self.trigger_reconnect(); + return Err(Error::IdleError(err)); + } } } // if we can't properly terminate the idle