Skip to content

Conversation

@Hocuri
Copy link
Collaborator

@Hocuri Hocuri commented Dec 18, 2025

There is a bug in pre-messages:

  • A pre-message adds an entry to the msgs table with the rfc724_mid of the post-message
  • If the pre-message and post-message are fetched in separate cycles:
    • prefetch_should_download() returns false, because rfc724_mid_exists() returns something
    • so, the message is not added to download_later, and never automatically downloaded.

This PR fixes the test at 73a2c94, if one adds these lines:

diff --git a/deltachat-rpc-client/tests/test_something.py b/deltachat-rpc-client/tests/test_something.py
index 9f9a40e32..2a9ce407a 100644
--- a/deltachat-rpc-client/tests/test_something.py
+++ b/deltachat-rpc-client/tests/test_something.py
@@ -979,5 +979,7 @@ def test_large_message(acfactory) -> None:
     )
 
     msg = bob.wait_for_incoming_msg()
+    msgs_changed_event = bob.wait_for_msgs_changed_event()
+    assert msg.id == msgs_changed_event.msg_id
     snapshot = msg.get_snapshot()
     assert snapshot.text == "Hello World, this message is bigger than 5 bytes"

and the test reproduces the bug if one adds:

diff --git a/src/smtp.rs b/src/smtp.rs
index 0a4ef049a..e936662e5 100644
--- a/src/smtp.rs
+++ b/src/smtp.rs
@@ -511,6 +511,8 @@ pub(crate) async fn send_smtp_messages(context: &Context, connection: &mut Smtp)
 
     info!(context, "Selected rows from SMTP queue: {rowids:?}.");
     for rowid in rowids {
+        info!(context, "Sleeping before sending.");
+        tokio::time::sleep(std::time::Duration::from_secs(2)).await;
         send_msg_to_smtp(context, connection, rowid)
             .await
             .context("Failed to send message")?;

@Hocuri Hocuri force-pushed the hoc/pre-messages-fix-prefetch_should_download branch from 58ebe1b to 55c89d1 Compare December 18, 2025 16:54
@Hocuri Hocuri changed the title [WIP] fix: Don't ignore post-messages that we have seen referenced by pre-message before fix: Don't ignore post-messages that we have seen referenced by pre-message before Dec 18, 2025
@Hocuri Hocuri requested a review from link2xt December 18, 2025 17:09
/// with the given `rfc724_mid`
/// and a download state other than `DownloadState::Available`
/// (i.e. a download state where it was already tried to download the message).
pub(crate) async fn downloaded_rfc724_mid_exists(
Copy link
Collaborator

@iequidoo iequidoo Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case, this function can be implemented as rfc724_mid_exists_ex(context, rfc724_mid, &format!("download_state={}", DownloadState::Available)).is_some_and(|x| !x.1). Not sure if this is better.

Also could be renamed to rfc724_mid_download_tried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants