From f2e5d13bb97dcef5f257a3eba523e97a81c159c3 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 22 Mar 2026 22:32:34 +0100 Subject: [PATCH] fix: delete available_post_msgs row if the message is already downloaded The row does not need to stay in the database only to be skipped each time. --- src/download.rs | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/download.rs b/src/download.rs index 2ec995fd8..9f3831b99 100644 --- a/src/download.rs +++ b/src/download.rs @@ -326,22 +326,25 @@ pub(crate) async fn download_known_post_messages_without_pre_message( }) .await?; for rfc724_mid in &rfc724_mids { - if !msg_is_downloaded_for(context, rfc724_mid).await? { - // Download the Post-Message unconditionally, - // because the Pre-Message got lost. - // The message may be in the wrong order, - // but at least we have it at all. - let res = download_msg(context, rfc724_mid.clone(), session).await; - if let Ok(Some(())) = res { - delete_from_available_post_msgs(context, rfc724_mid).await?; - } - if let Err(err) = res { - warn!( - context, - "download_known_post_messages_without_pre_message: Failed to download message rfc724_mid={rfc724_mid}: {:#}.", - err - ); - } + if msg_is_downloaded_for(context, rfc724_mid).await? { + delete_from_available_post_msgs(context, rfc724_mid).await?; + continue; + } + + // Download the Post-Message unconditionally, + // because the Pre-Message got lost. + // The message may be in the wrong order, + // but at least we have it at all. + let res = download_msg(context, rfc724_mid.clone(), session).await; + if let Ok(Some(())) = res { + delete_from_available_post_msgs(context, rfc724_mid).await?; + } + if let Err(err) = res { + warn!( + context, + "download_known_post_messages_without_pre_message: Failed to download message rfc724_mid={rfc724_mid}: {:#}.", + err + ); } } Ok(())