Commit 86811e32 authored by David Douard's avatar David Douard
Browse files

[mboximport] import the mail box messages sorted by date (closes #2515093)

This is required since the EmailThread creation logic strongly rely on the order which Email entities are created
parent 277d815fe802
......@@ -64,9 +64,11 @@ class MBOXImporter(object):
self.skipped.append(messageid)
def import_mbox_stream(self, stream):
from mailbox import UnixMailbox
from mailbox import UnixMailbox as Mailbox
from rfc822 import parsedate
from logilab.common.umessage import message_from_file
for message in UnixMailbox(stream, message_from_file):
for message in sorted(Mailbox(stream, message_from_file),
key=lambda x:parsedate(x['Date'])):
try:
self.import_message(message)
if self.autocommit:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment