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.
This commit is contained in:
Alexander Krotov
2020-04-25 01:43:26 +03:00
parent 3d6ca973c4
commit 46fb6a21ee

View File

@@ -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":