From 7729355e679bb8f7e2cef2caf6219664a333006f Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 26 Aug 2014 17:42:39 -0500 Subject: fix and migrate tests to trial We cannot use setUpClass when running tests with trial. But, after all, it's not *so* expensive to initialize a new soledad instance (since we'll be mostly using the memstore for the tests). --- src/leap/mail/imap/mailbox.py | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 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 47c7ff1..aa2a300 100644 --- a/src/leap/mail/imap/mailbox.py +++ b/src/leap/mail/imap/mailbox.py @@ -214,6 +214,7 @@ class SoledadMailbox(WithMsgFields, MBoxParser): """ return self._memstore.get_mbox_doc(self.mbox) + # XXX the memstore->soledadstore method in memstore is not complete def getFlags(self): """ Returns the flags defined for this mailbox. @@ -221,21 +222,12 @@ class SoledadMailbox(WithMsgFields, MBoxParser): :returns: tuple of flags for this mailbox :rtype: tuple of str """ - flags = self.INIT_FLAGS - - # XXX returning fixed flags always - # Since I have not found a case where the client - # wants to modify this, as a way of speeding up - # selects. To do it right, we probably should keep - # track of the set of all flags used by msgs - # in this mailbox. Does it matter? - #mbox = self._get_mbox_doc() - #if not mbox: - #return None - #flags = mbox.content.get(self.FLAGS_KEY, []) + flags = self._memstore.get_mbox_flags(self.mbox) + if not flags: + flags = self.INIT_FLAGS return map(str, flags) - # XXX move to memstore->soledadstore + # XXX the memstore->soledadstore method in memstore is not complete def setFlags(self, flags): """ Sets flags for this mailbox. @@ -243,15 +235,10 @@ class SoledadMailbox(WithMsgFields, MBoxParser): :param flags: a tuple with the flags :type flags: tuple of str """ + # XXX this is setting (overriding) old flags. leap_assert(isinstance(flags, tuple), "flags expected to be a tuple") - mbox = self._get_mbox_doc() - if not mbox: - return None - mbox.content[self.FLAGS_KEY] = map(str, flags) - logger.debug("Writing mbox document for %r to Soledad" - % (self.mbox,)) - self._soledad.put_doc(mbox) + self._memstore.set_mbox_flags(self.mbox, flags) # XXX SHOULD BETTER IMPLEMENT ADD_FLAG, REMOVE_FLAG. @@ -301,6 +288,9 @@ class SoledadMailbox(WithMsgFields, MBoxParser): primed = self._last_uid_primed.get(self.mbox, False) if not primed: mbox = self._get_mbox_doc() + if mbox is None: + # memory-only store + return last = mbox.content.get('lastuid', 0) logger.info("Priming Soledad last_uid to %s" % (last,)) self._memstore.set_last_soledad_uid(self.mbox, last) @@ -531,6 +521,8 @@ class SoledadMailbox(WithMsgFields, MBoxParser): Should cleanup resources, and set the \\Noselect flag on the mailbox. """ + # XXX this will overwrite all the existing flags! + # should better simply addFlag self.setFlags((self.NOSELECT_FLAG,)) self.deleteAllDocs() @@ -538,6 +530,10 @@ class SoledadMailbox(WithMsgFields, MBoxParser): # we should postpone the removal # XXX move to memory store?? + mbox_doc = self._get_mbox_doc() + if mbox_doc is None: + # memory-only store! + return self._soledad.delete_doc(self._get_mbox_doc()) def _close_cb(self, result): @@ -640,7 +636,7 @@ class SoledadMailbox(WithMsgFields, MBoxParser): # switch to content-hash based index + local UID table. sequence = False - #sequence = True if uid == 0 else False + # sequence = True if uid == 0 else False messages_asked = self._bound_seq(messages_asked) seq_messg = self._filter_msg_seq(messages_asked) -- cgit v1.2.3 From ad568dd45ead0b87e09a26fc7f5bf0c6c5a63324 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 9 Sep 2014 10:18:50 -0500 Subject: add comment --- src/leap/mail/imap/mailbox.py | 2 ++ 1 file changed, 2 insertions(+) (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 aa2a300..34cf535 100644 --- a/src/leap/mail/imap/mailbox.py +++ b/src/leap/mail/imap/mailbox.py @@ -459,6 +459,8 @@ class SoledadMailbox(WithMsgFields, MBoxParser): notify_on_disk=notify_on_disk) if PROFILE_CMD: do_profile_cmd(d, "APPEND") + + # XXX should review now that we're not using qtreactor. # A better place for this would be the COPY/APPEND dispatcher # in server.py, but qtreactor hangs when I do that, so this seems # to work fine for now. -- cgit v1.2.3