diff --git a/src/imap/mod.rs b/src/imap/mod.rs index 3eb0c6dc2..be919b5c4 100644 --- a/src/imap/mod.rs +++ b/src/imap/mod.rs @@ -994,10 +994,10 @@ impl Imap { context: &Context, message_id: &str, folder: &str, - uid: &mut u32, + uid: u32, ) -> ImapActionResult { task::block_on(async move { - if let Some(imapresult) = self.prepare_imap_operation_on_msg(context, folder, *uid) { + if let Some(imapresult) = self.prepare_imap_operation_on_msg(context, folder, uid) { return imapresult; } // we are connected, and the folder is selected @@ -1034,7 +1034,7 @@ impl Imap { remote_message_id, message_id, ); - *uid = 0; + return ImapActionResult::Failed; } } Err(err) => { @@ -1042,18 +1042,18 @@ impl Imap { context, "Cannot delete {} on IMAP: {}", display_imap_id, err ); - *uid = 0; + return ImapActionResult::RetryLater; } } } // mark the message for deletion - if !self.add_flag_finalized(context, *uid, "\\Deleted").await { + if !self.add_flag_finalized(context, uid, "\\Deleted").await { warn!( context, "Cannot mark message {} as \"Deleted\".", display_imap_id ); - ImapActionResult::Failed + ImapActionResult::RetryLater } else { emit_event!( context, diff --git a/src/job.rs b/src/job.rs index 04a8af69d..684457823 100644 --- a/src/job.rs +++ b/src/job.rs @@ -449,7 +449,7 @@ impl Job { fn DeleteMsgOnImap(&mut self, context: &Context) -> Status { let imap_inbox = &context.inbox_thread.read().unwrap().imap; - let mut msg = job_try!(Message::load_from_db(context, MsgId::new(self.foreign_id))); + let msg = job_try!(Message::load_from_db(context, MsgId::new(self.foreign_id))); if !msg.rfc724_mid.is_empty() { if message::rfc724_mid_cnt(context, &msg.rfc724_mid) > 1 { @@ -462,10 +462,15 @@ impl Job { we delete the message from the server */ let mid = msg.rfc724_mid; let server_folder = msg.server_folder.as_ref().unwrap(); - let res = imap_inbox.delete_msg(context, &mid, server_folder, &mut msg.server_uid); - if res == ImapActionResult::RetryLater { - // XXX RetryLater is converted to RetryNow here - return Status::RetryNow; + let res = 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"))); + } } } Message::delete_from_db(context, msg.id);