mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16:31 +03:00
fix: Don't fall into infinite loop if the folder is missing (#8021)
Previously, if the mvbox_move folder is missing, then core will loop infinitely, because `new_mail` is never set to false. The fix is to first set `new_mail` to false, then return if the folder is missing. This is the bug @hpk42 experienced when commenting in https://github.com/chatmail/core/issues/7989 --------- Co-authored-by: holger krekel <holger@merlinux.eu>
This commit is contained in:
10
src/imap.rs
10
src/imap.rs
@@ -561,16 +561,19 @@ impl Imap {
|
|||||||
.select_with_uidvalidity(context, folder)
|
.select_with_uidvalidity(context, folder)
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("Failed to select folder {folder:?}"))?;
|
.with_context(|| format!("Failed to select folder {folder:?}"))?;
|
||||||
if !folder_exists {
|
|
||||||
return Ok(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if !session.new_mail {
|
if !session.new_mail {
|
||||||
info!(context, "No new emails in folder {folder:?}.");
|
info!(context, "No new emails in folder {folder:?}.");
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
// Make sure not to return before setting new_mail to false
|
||||||
|
// Otherwise, we will skip IDLE and go into an infinite loop
|
||||||
session.new_mail = false;
|
session.new_mail = false;
|
||||||
|
|
||||||
|
if !folder_exists {
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
|
||||||
let mut read_cnt = 0;
|
let mut read_cnt = 0;
|
||||||
loop {
|
loop {
|
||||||
let (n, fetch_more) = self
|
let (n, fetch_more) = self
|
||||||
@@ -1237,6 +1240,7 @@ impl Session {
|
|||||||
// have been modified while our request was in progress.
|
// have been modified while our request was in progress.
|
||||||
// We may or may not have these new flags as a part of the response,
|
// We may or may not have these new flags as a part of the response,
|
||||||
// so better skip next IDLE and do another round of flag synchronization.
|
// so better skip next IDLE and do another round of flag synchronization.
|
||||||
|
info!(context, "Got unsolicited fetch, will skip idle");
|
||||||
self.new_mail = true;
|
self.new_mail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user