mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
fake_idle: unwrap watch_folder early to avoid doing it in a loop
This also makes info message "IMAP-fake-IDLEing folder=..." nicer, because the folder name is not wrapped into Some() anymore.
This commit is contained in:
@@ -125,10 +125,12 @@ impl Imap {
|
|||||||
let fake_idle_start_time = SystemTime::now();
|
let fake_idle_start_time = SystemTime::now();
|
||||||
|
|
||||||
// Do not poll, just wait for an interrupt when no folder is passed in.
|
// Do not poll, just wait for an interrupt when no folder is passed in.
|
||||||
if watch_folder.is_none() {
|
let watch_folder = if let Some(watch_folder) = watch_folder {
|
||||||
|
watch_folder
|
||||||
|
} else {
|
||||||
info!(context, "IMAP-fake-IDLE: no folder, waiting for interrupt");
|
info!(context, "IMAP-fake-IDLE: no folder, waiting for interrupt");
|
||||||
return self.idle_interrupt.recv().await.unwrap_or_default();
|
return self.idle_interrupt.recv().await.unwrap_or_default();
|
||||||
}
|
};
|
||||||
info!(context, "IMAP-fake-IDLEing folder={:?}", watch_folder);
|
info!(context, "IMAP-fake-IDLEing folder={:?}", watch_folder);
|
||||||
|
|
||||||
// check every minute if there are new messages
|
// check every minute if there are new messages
|
||||||
@@ -170,8 +172,7 @@ impl Imap {
|
|||||||
// will have already fetched the messages so perform_*_fetch
|
// will have already fetched the messages so perform_*_fetch
|
||||||
// will not find any new.
|
// will not find any new.
|
||||||
|
|
||||||
if let Some(ref watch_folder) = watch_folder {
|
match self.fetch_new_messages(context, &watch_folder, false).await {
|
||||||
match self.fetch_new_messages(context, watch_folder, false).await {
|
|
||||||
Ok(res) => {
|
Ok(res) => {
|
||||||
info!(context, "fetch_new_messages returned {:?}", res);
|
info!(context, "fetch_new_messages returned {:?}", res);
|
||||||
if res {
|
if res {
|
||||||
@@ -184,7 +185,6 @@ impl Imap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Event::Interrupt(info) => {
|
Event::Interrupt(info) => {
|
||||||
// Interrupt
|
// Interrupt
|
||||||
break info;
|
break info;
|
||||||
|
|||||||
Reference in New Issue
Block a user