From 46fb6a21ee7efdc608b5ee9e0f459ac79e8e9840 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 25 Apr 2020 01:43:26 +0300 Subject: [PATCH] job: perform no more than 20 IMAP jobs in a row Let the thread load new messages. This may happen when user switches the setting to delete messages on the server on and there are a lot of messages to delete. --- src/job.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/job.rs b/src/job.rs index d4879b574..7e101b9f6 100644 --- a/src/job.rs +++ b/src/job.rs @@ -1043,7 +1043,17 @@ pub fn perform_sentbox_jobs(context: &Context) { } fn job_perform(context: &Context, thread: Thread, probe_network: bool) { + let mut jobs_loaded = 0; + while let Some(mut job) = load_next_job(context, thread, probe_network) { + jobs_loaded += 1; + if thread == Thread::Imap && jobs_loaded > 20 { + // Let the fetch run, but return back to the job afterwards. + info!(context, "postponing {}-job {} to run fetch...", thread, job); + *context.perform_inbox_jobs_needed.write().unwrap() = true; + break; + } + info!(context, "{}-job {} started...", thread, job); // some configuration jobs are "exclusive":