Browse Source

melib/imap: set conn to Err if watch returns Err

master
Manos Pitsidianakis 2 years ago
parent
commit
96985c9c1f
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 20
      melib/src/backends/imap.rs

20
melib/src/backends/imap.rs

@ -452,15 +452,29 @@ impl MailBackend for ImapType {
};
Ok(Box::pin(async move {
debug!(has_idle);
let main_conn2 = main_conn.clone();
let kit = ImapWatchKit {
conn,
main_conn,
uid_store,
};
if has_idle {
idle(kit).await?;
if let Err(err) = if has_idle {
idle(kit).await
} else {
poll_with_examine(kit).await?;
poll_with_examine(kit).await
} {
let mut main_conn = timeout(Duration::from_secs(3), main_conn2.lock()).await?;
if err.kind.is_network() {
main_conn.uid_store.is_online.lock().unwrap().1 = Err(err.clone());
}
debug!("failure: {}", err.to_string());
let account_hash = main_conn.uid_store.account_hash;
main_conn.add_refresh_event(RefreshEvent {
account_hash,
mailbox_hash: 0,
kind: RefreshEventKind::Failure(err.clone()),
});
return Err(err);
}
debug!("watch future returning");
Ok(())

Loading…
Cancel
Save