[PATCH] Sort message UID list
James E. Blair
corvus at inaugust.com
Sun Jul 8 17:44:42 BST 2012
On 07/08/2012 08:26 AM, Dave Abrahams wrote:
>
> on Sat Jul 07 2012, corvus-AT-gnu.org (James E. Blair) wrote:
>
>> Return a sorted list of UIDs in getmessageuidlist.
...
> Would you mind explaining what practical difference this change makes
> for a user of offlineimap?
I generally use two mail clients: GNUS and Thunderbird. Both of them
can be configured to show messages in the order received by the IMAP
server, or, more precisely, in UID order. This is generally very
similar to sorting by the Date header, however, it is not prone to being
fooled by erroneous dates, such as the odd message that has a Date far
in the past that shows up at the top of the list of messages, or one
that is 37 years in the future that will keep showing up at the bottom
of the list for the next 37 years. Anyway, that's all background for
why someone might want to sort in UID order.
So how that interacts with offlineimap is that when OI copies messages
from one IMAP server to another, it iterates over a list of UIDs and
copies each one in turn. That list of UIDs is currently unsorted. OI
gets a sorted list of UIDs from the source server, but due to the way it
stores them in memory while working, they become unsorted. This change
sorts them again before using them, so the messages being copied should
be in the same order on both servers.
In practical terms, this has the most impact for a first-time sync on an
existing large mailbox. When I did this on a folder with 10,000
messages, I noticed they were copied over in fairly random chunks, with
UIDs like: 1,2,3,4,23847,23848,23849,5,6,7,8,... meaning that a sort by
UID was useless -- at the bottom of the list I'd see messages from 6
months ago, and just above that, messages from today.
Obviously after an initial sync, the intervals between offlineimap runs
are going to be smaller, and the order of copying over, say, 5 messages
isn't going to matter much. But it's still more correct to copy them in
order.
The bottom line is: if you don't care about UID order, then this patch
isn't going to affect you at all. Copied in random order or UID order,
your messages will get to the other side. If you do care about UID
order, then this patch makes a huge difference -- it's absolutely
required in order to sort messages correctly.
-Jim
More information about the OfflineIMAP-project
mailing list