[PATCH] Sort message UID list

James E. Blair corvus at gnu.org
Sun Jul 8 04:16:56 BST 2012


Return a sorted list of UIDs in getmessageuidlist.

Some MUAs (and their users) like to display messages in UID order
(or "order received").  If offlineimap is used in IMAP<->IMAP mode,
then the order messages are received by the second IMAP server will
be different because offlineimap iterates over a UID list produced
from the keys of a dictionary, which is unsorted.

This change sorts that list of UIDs so that both IMAP servers will
have their messages in the same order (except those times where
messages are appended to folders on both repositories between
syncs).

Signed-off-by: James E. Blair <corvus at gnu.org>
---
 offlineimap/folder/Base.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py
index 6f6f364..1052552 100644
--- a/offlineimap/folder/Base.py
+++ b/offlineimap/folder/Base.py
@@ -181,7 +181,7 @@ class BaseFolder(object):
     def getmessageuidlist(self):
         """Gets a list of UIDs.
         You may have to call cachemessagelist() before calling this function!"""
-        return self.getmessagelist().keys()
+        return sorted(self.getmessagelist().keys())
 
     def getmessagecount(self):
         """Gets the number of messages."""
-- 
1.7.9.5





More information about the OfflineIMAP-project mailing list