diff --git a/src/imap/idle.rs b/src/imap/idle.rs index 4980bbc2c..f6b1052da 100644 --- a/src/imap/idle.rs +++ b/src/imap/idle.rs @@ -101,7 +101,7 @@ impl Imap { pub(crate) async fn fake_idle( &mut self, context: &Context, - watch_folder: Option, + watch_folder: String, folder_meaning: FolderMeaning, ) { // Idle using polling. This is also needed if we're not yet configured - @@ -110,13 +110,6 @@ impl Imap { let fake_idle_start_time = tools::Time::now(); // Do not poll, just wait for an interrupt when no folder is passed in. - let watch_folder = if let Some(watch_folder) = watch_folder { - watch_folder - } else { - info!(context, "IMAP-fake-IDLE: no folder, waiting for interrupt"); - self.idle_interrupt_receiver.recv().await.ok(); - return; - }; info!(context, "IMAP-fake-IDLEing folder={:?}", watch_folder); const TIMEOUT_INIT_MS: u64 = 60_000; diff --git a/src/scheduler.rs b/src/scheduler.rs index 0822b9f7d..96047e36e 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -541,9 +541,7 @@ async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder_meaning: Folder ctx, "Cannot watch {folder_meaning}, ensure_configured_folders() failed: {:#}", err, ); - connection - .fake_idle(ctx, None, FolderMeaning::Unknown) - .await; + connection.idle_interrupt_receiver.recv().await.ok(); return; } let (folder_config, watch_folder) = match convert_folder_meaning(ctx, folder_meaning).await { @@ -554,9 +552,7 @@ async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder_meaning: Folder // but watching Sent folder is enabled. warn!(ctx, "Error converting IMAP Folder name: {:?}", error); connection.connectivity.set_not_configured(ctx).await; - connection - .fake_idle(ctx, None, FolderMeaning::Unknown) - .await; + connection.idle_interrupt_receiver.recv().await.ok(); return; } }; @@ -657,7 +653,7 @@ async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder_meaning: Folder let Some(session) = connection.session.take() else { warn!(ctx, "No IMAP session, going to fake idle."); connection - .fake_idle(ctx, Some(watch_folder), folder_meaning) + .fake_idle(ctx, watch_folder, folder_meaning) .await; return; }; @@ -668,7 +664,7 @@ async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder_meaning: Folder "IMAP session does not support IDLE, going to fake idle." ); connection - .fake_idle(ctx, Some(watch_folder), folder_meaning) + .fake_idle(ctx, watch_folder, folder_meaning) .await; return; } @@ -682,7 +678,7 @@ async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder_meaning: Folder { info!(ctx, "IMAP IDLE is disabled, going to fake idle."); connection - .fake_idle(ctx, Some(watch_folder), folder_meaning) + .fake_idle(ctx, watch_folder, folder_meaning) .await; return; }