Skip to content

Sorting by INTERNALDATE may result in lost messages #7903

@link2xt

Description

@link2xt

Here prefetch returns messages by INTERNALDATE:

core/src/imap.rs

Lines 605 to 608 in 8df9b9e

let msgs = session
.prefetch(old_uid_next, uids_to_prefetch)
.await
.context("prefetch")?;

Because of this UIDs in this loop come in arbitrary order:

for (uid, ref fetch_response) in msgs {

But here we update largest_uid_fetched assuming UIDs don't decrease:

largest_uid_fetched = max(largest_uid_fetched, uid);

So if e.g. we prefetch UIDs 1, 3, 2, then fetch 1 and 3 but fail before 2, largest fetched UID would be 3 and we will next time not fetch UID 2.

This INTERNALDATE sorting comes from #3789, it is needed to revert the problem of providers that reorder messages when MOVE is used on a batch of messages.

After removing mvbox_move we don't need to sort prefetch by INTERNALDATE and can sort it by UID.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions