From 6553d8ec44346d125969251d15d943ae58da264e Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Mon, 29 Jun 2020 17:56:23 +0300 Subject: [PATCH] imap_saync: fix max_uid invariant violation --- melib/src/backends/imap_async.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/melib/src/backends/imap_async.rs b/melib/src/backends/imap_async.rs index 15ac3b4b..1e255a7d 100644 --- a/melib/src/backends/imap_async.rs +++ b/melib/src/backends/imap_async.rs @@ -702,7 +702,8 @@ impl MailBackend for ImapType { sender: RefreshEventConsumer, work_context: WorkContext, ) -> Result { - Err(MeliError::new("Unimplemented.")) + Ok(std::thread::current().id()) + //Err(MeliError::new("Unimplemented.")) //unimplemented!() /* let conn = ImapConnection::new_connection(&self.server_conf, self.uid_store.clone()); @@ -1807,9 +1808,13 @@ async fn get_hlpr( .insert_existing_set(envelopes.iter().map(|(_, env)| env.hash()).collect::<_>()); payload.extend(envelopes.into_iter().map(|(_, env)| env)); } - *max_uid = Some(std::cmp::max( - std::cmp::max(max_uid_left.saturating_sub(chunk_size), 1), - 1, - )); + *max_uid = if max_uid_left == 1 { + Some(0) + } else { + Some(std::cmp::max( + std::cmp::max(max_uid_left.saturating_sub(chunk_size), 1), + 1, + )) + }; Ok(payload) }