Skip to content

Commit 22e5bf8

Browse files
committed
fix(download_msg): do not fail if the message does not exist anymore
Without this fix IMAP loop may get stuck trying to download non-existing message over and over like this: ``` src/imap.rs:372: Logging into IMAP server with LOGIN. src/imap.rs:388: Successfully logged into IMAP server src/scheduler.rs:361: Failed to download message Msg#3467: Message Msg#3467 does not exist. src/scheduler.rs:418: Failed fetch_idle: Failed to download messages: Message Msg#3467 does not exist ``` The whole download operation fails due to attempt to set the state of non-existing message to "failed". Now download of the message will "succeed" if the message does not exist and we don't try to set its state.
1 parent c8ba516 commit 22e5bf8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/download.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,17 @@ pub(crate) async fn download_msg(
135135
msg_id: MsgId,
136136
session: &mut Session,
137137
) -> Result<()> {
138-
let msg = Message::load_from_db(context, msg_id).await?;
138+
let Some(msg) = Message::load_from_db_optional(context, msg_id).await? else {
139+
// If partially downloaded message was already deleted
140+
// we do not know its Message-ID anymore
141+
// so cannot download it.
142+
//
143+
// Probably the message expired due to `delete_device_after`
144+
// setting or was otherwise removed from the device,
145+
// so we don't want it to reappear anyway.
146+
return Ok(());
147+
};
148+
139149
let row = context
140150
.sql
141151
.query_row_optional(

0 commit comments

Comments
 (0)