mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 02:46:29 +03:00
feat: advance next UID even if connection fails while fetching
Connection sometimes fails while processing FETCH responses. In this case `fetch_new_messages` exits early and does not advance next expected UID even if some messages were processed. This results in prefetching the same messages after reconnection and log messages similar to "Not moving the message ab05c85a-e191-4fd2-a951-9972bc7e167f@localhost that we have seen before.". With this change we advance next expected UID even if `fetch_new_messages` returns a network error.
This commit is contained in:
@@ -213,17 +213,18 @@ impl Session {
|
||||
|
||||
let mut uid_message_ids: BTreeMap<u32, String> = BTreeMap::new();
|
||||
uid_message_ids.insert(uid, rfc724_mid);
|
||||
let (last_uid, _received) = self
|
||||
.fetch_many_msgs(
|
||||
context,
|
||||
folder,
|
||||
uidvalidity,
|
||||
vec![uid],
|
||||
&uid_message_ids,
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
if last_uid.is_none() {
|
||||
let (sender, receiver) = async_channel::unbounded();
|
||||
self.fetch_many_msgs(
|
||||
context,
|
||||
folder,
|
||||
uidvalidity,
|
||||
vec![uid],
|
||||
&uid_message_ids,
|
||||
false,
|
||||
sender,
|
||||
)
|
||||
.await?;
|
||||
if receiver.recv().await.is_err() {
|
||||
bail!("Failed to fetch UID {uid}");
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user