melib/imap: Lazy evaluate idle capability

With the eager evaluation, you run the risk of checking the capabilities
store before any connection to the server may have been opened.
Therefore, the capabilities uid_store will be empty and it will fall
back to poll_with_examine even if the server might have support for
idle.
jmap-eventsource
Zisu Andrei 2020-12-24 11:46:15 +00:00 committed by Manos Pitsidianakis
parent 9124ad0ae7
commit 0034f195e3
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 13 additions and 13 deletions

View File

@ -453,20 +453,20 @@ impl MailBackend for ImapType {
let server_conf = self.server_conf.clone();
let main_conn = self.connection.clone();
let uid_store = self.uid_store.clone();
let has_idle: bool = match self.server_conf.protocol {
ImapProtocol::IMAP {
extension_use: ImapExtensionUse { idle, .. },
} => {
idle && uid_store
.capabilities
.lock()
.unwrap()
.iter()
.any(|cap| cap.eq_ignore_ascii_case(b"IDLE"))
}
_ => false,
};
Ok(Box::pin(async move {
let has_idle: bool = match server_conf.protocol {
ImapProtocol::IMAP {
extension_use: ImapExtensionUse { idle, .. },
} => {
idle && uid_store
.capabilities
.lock()
.unwrap()
.iter()
.any(|cap| cap.eq_ignore_ascii_case(b"IDLE"))
}
_ => false,
};
while let Err(err) = if has_idle {
idle(ImapWatchKit {
conn: ImapConnection::new_connection(&server_conf, uid_store.clone()),