Skip to content

Commit

Permalink
Revert "fix: check UIDNEXT with a STATUS command before going IDLE"
Browse files Browse the repository at this point in the history
This reverts commit 2e50abe.

STATUS is broken on mail.163.com.
It returns `STATUS "INBOX" ()` reply
when `STATUS "INBOX" (UIDNEXT)` is requested.
  • Loading branch information
link2xt committed Nov 24, 2023
1 parent 9b751c1 commit 7ff7d82
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions src/imap/idle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::session::Session;
use super::Imap;
use crate::config::Config;
use crate::context::Context;
use crate::imap::{client::IMAP_TIMEOUT, get_uid_next, FolderMeaning};
use crate::imap::{client::IMAP_TIMEOUT, FolderMeaning};
use crate::log::LogExt;

const IDLE_TIMEOUT: Duration = Duration::from_secs(23 * 60);
Expand All @@ -29,29 +29,6 @@ impl Session {
return Ok(self);
}

// Despite checking for unsolicited EXISTS above,
// we may have missed EXISTS if the message was
// received when the folder was not selected.
let status = self
.status(folder, "(UIDNEXT)")
.await
.with_context(|| format!("STATUS (UIDNEXT) error for {folder:?}"))?;
if let Some(uid_next) = status.uid_next {
let expected_uid_next = get_uid_next(context, folder)
.await
.with_context(|| format!("failed to get old UID NEXT for folder {folder}"))?;
if uid_next > expected_uid_next {
info!(
context,
"Skipping IDLE on {folder:?} because UIDNEXT {uid_next}>{expected_uid_next} indicates there are new messages."
);
return Ok(self);
}
} else {
warn!(context, "STATUS {folder} (UIDNEXT) did not return UIDNEXT");
// Go to IDLE anyway if STATUS is broken.
}

if let Ok(()) = idle_interrupt_receiver.try_recv() {
info!(context, "skip idle, got interrupt");
return Ok(self);
Expand Down

0 comments on commit 7ff7d82

Please sign in to comment.