Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion deltachat-rpc-client/tests/test_something.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pytest

from deltachat_rpc_client import EventType, events
from deltachat_rpc_client.const import MessageState, DownloadState
from deltachat_rpc_client.const import MessageState
from deltachat_rpc_client.pytestplugin import E2EE_INFO_MSGS
from deltachat_rpc_client.rpc import JsonRpcError

Expand Down Expand Up @@ -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"
6 changes: 1 addition & 5 deletions src/imap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2284,11 +2284,7 @@ pub(crate) async fn prefetch_should_download(
message_id: &str,
mut flags: impl Iterator<Item = Flag<'_>>,
) -> Result<bool> {
if message::rfc724_mid_exists(context, message_id)
.await?
.is_some()
{
markseen_on_imap_table(context, message_id).await?;
if message::rfc724_mid_download_tried(context, message_id).await? {
return Ok(false);
}

Expand Down
26 changes: 26 additions & 0 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2176,6 +2176,32 @@ pub(crate) async fn rfc724_mid_exists_ex(
Ok(res)
}

/// Returns `true` iff there is a message
/// 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 rfc724_mid_download_tried(context: &Context, rfc724_mid: &str) -> Result<bool> {
let rfc724_mid = rfc724_mid.trim_start_matches('<').trim_end_matches('>');
if rfc724_mid.is_empty() {
warn!(
context,
"Empty rfc724_mid passed to rfc724_mid_download_tried"
);
return Ok(false);
}

let res = context
.sql
.exists(
"SELECT COUNT(*) FROM msgs
WHERE rfc724_mid=? AND download_state<>?",
(rfc724_mid, DownloadState::Available),
)
.await?;

Ok(res)
}

/// Given a list of Message-IDs, returns the most relevant message found in the database.
///
/// Relevance here is `(download_state == Done, index)`, where `index` is an index of Message-ID in
Expand Down
Loading