melib/imap: prevent false IDLE wakeups

Prevent IDLE loop waking up when receiving continuation "+ " lines
master
Manos Pitsidianakis 2020-09-11 00:12:34 +03:00
parent 5cd03fff0f
commit 1751509739
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 29 additions and 3 deletions

View File

@ -145,14 +145,40 @@ pub async fn idle(kit: ImapWatchKit) -> Result<()> {
}
watch = now;
}
if to_str!(&line)
.split_rn()
.filter(|l| {
!l.starts_with("+ ")
&& !l.starts_with("* ok")
&& !l.starts_with("* ok")
&& !l.starts_with("* Ok")
&& !l.starts_with("* OK")
})
.count()
== 0
{
let mut conn = timeout(Duration::from_secs(10), main_conn.lock()).await?;
conn.examine_mailbox(mailbox_hash, &mut response, false)
continue;
}
{
blockn.conn.send_raw(b"DONE").await?;
blockn
.conn
.read_response(&mut response, RequiredResponses::empty())
.await?;
for l in to_str!(&line).split_rn() {
debug!("process_untagged {:?}", &l);
conn.process_untagged(l).await?;
if l.starts_with("+ ")
|| l.starts_with("* ok")
|| l.starts_with("* ok")
|| l.starts_with("* Ok")
|| l.starts_with("* OK")
{
debug!("ignore continuation mark");
continue;
}
blockn.conn.process_untagged(l).await?;
}
blockn.conn.send_command(b"IDLE").await?;
}
*uid_store.is_online.lock().unwrap() = (Instant::now(), Ok(()));
}