From c4677190be584bb6501a0ea7e359b8dea128526d Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 7 Mar 2020 20:33:56 +0300 Subject: [PATCH] Postpone DeleteMsgOnImap on error If job returns Status::Finished, it will be deleted. Then add_imap_deletion_jobs will recreate it immediately if the message is expired. To actually backoff the job, we should postpone it instead of removing. --- src/job.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/job.rs b/src/job.rs index 4ad83b762..1fc75336c 100644 --- a/src/job.rs +++ b/src/job.rs @@ -469,12 +469,16 @@ impl Job { imap_inbox.delete_msg(context, &mid, server_folder, msg.server_uid) }; match res { - ImapActionResult::RetryLater => { - return Status::RetryLater; - } ImapActionResult::AlreadyDone | ImapActionResult::Success => {} - ImapActionResult::Failed => { - return Status::Finished(Err(format_err!("Message deletion failed"))); + ImapActionResult::RetryLater | ImapActionResult::Failed => { + // If job has failed, for example due to some + // IMAP bug, we postpone it instead of failing + // immediately. This will prevent adding it + // immediately again if user has enabled + // automatic message deletion. Without this, + // we might waste a lot of traffic constantly + // retrying message deletion. + return Status::RetryLater; } } }