Unlock session before calling add_flag_finalized

add_flag_finalized tries to lock session again and IMAP thread deadlocks
if session is not unlocked.
This commit is contained in:
Alexander Krotov
2020-02-12 03:10:40 +03:00
parent 7e9585ebc5
commit beb91271de

View File

@@ -866,8 +866,14 @@ impl Imap {
} }
if let Some(ref mut session) = &mut *self.session.lock().await { if let Some(ref mut session) = &mut *self.session.lock().await {
match session.uid_copy(&set, &dest_folder).await { if let Err(err) = session.uid_copy(&set, &dest_folder).await {
Ok(_) => { warn!(context, "Could not copy message: {}", err);
return ImapActionResult::Failed;
}
} else {
unreachable!();
}
if !self.add_flag_finalized(context, uid, "\\Deleted").await { if !self.add_flag_finalized(context, uid, "\\Deleted").await {
warn!(context, "Cannot mark {} as \"Deleted\" after copy.", uid); warn!(context, "Cannot mark {} as \"Deleted\" after copy.", uid);
emit_event!( emit_event!(
@@ -889,15 +895,6 @@ impl Imap {
); );
ImapActionResult::Success ImapActionResult::Success
} }
}
Err(err) => {
warn!(context, "Could not copy message: {}", err);
ImapActionResult::Failed
}
}
} else {
unreachable!();
}
}) })
} }