From bd5f777ff5e9f4fd81afeebb17074326b2671cd1 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Mon, 2 Mar 2015 15:00:12 -0400 Subject: [bug] Fix testExpunge tests this test was failing randomly because we were returning the deferred before all the documents were saved into soledad store. changed also the delete_msg deferred chaining for better readability. Releases: 0.9.0 --- src/leap/mail/imap/mailbox.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'src/leap/mail/imap/mailbox.py') diff --git a/src/leap/mail/imap/mailbox.py b/src/leap/mail/imap/mailbox.py index 91c6549..61baca5 100644 --- a/src/leap/mail/imap/mailbox.py +++ b/src/leap/mail/imap/mailbox.py @@ -307,7 +307,7 @@ class IMAPMailbox(object): d.addCallback(as_a_dict) return d - def addMessage(self, message, flags, date=None): + def addMessage(self, message, flags, date=None, notify_just_mdoc=True): """ Adds a message to this mailbox. @@ -327,6 +327,21 @@ class IMAPMailbox(object): # TODO have a look at the cases for internal date in the rfc # XXX we could treat the message as an IMessage from here + # TODO notify_just_mdoc *sometimes* make the append tests fail. + # have to find a better solution for this. A workaround could probably + # be to have a list of the ongoing deferreds related to append, so that + # we queue for later all the requests having to do with these. + + # notify_just_mdoc=True: feels HACKY, but improves a *lot* the + # responsiveness of the APPENDS: we just need to be notified when the + # mdoc is saved, and let's hope that the other parts are doing just + # fine. This will not catch any errors when the inserts of the other + # parts fail, but on the other hand allows us to return very quickly, + # which seems a good compromise given that we have to serialize the + # appends. + # A better solution will probably involve implementing MULTIAPPEND + # extension or patching imap server to support pipelining. + if isinstance(message, (cStringIO.OutputType, StringIO.StringIO)): message = message.getvalue() @@ -340,19 +355,9 @@ class IMAPMailbox(object): if date is None: date = formatdate(time.time()) - # notify_just_mdoc=True: feels HACKY, but improves a *lot* the - # responsiveness of the APPENDS: we just need to be notified when the - # mdoc is saved, and let's hope that the other parts are doing just - # fine. This will not catch any errors when the inserts of the other - # parts fail, but on the other hand allows us to return very quickly, - # which seems a good compromise given that we have to serialize the - # appends. - # A better solution will probably involve implementing MULTIAPPEND - # extension or patching imap server to support pipelining. - # TODO add notify_new as a callback here... return self.collection.add_msg(message, flags, date=date, - notify_just_mdoc=True) + notify_just_mdoc=notify_just_mdoc) def notify_new(self, *args): """ -- cgit v1.2.3