diff options
author | Kali Kaneko <kali@leap.se> | 2014-02-02 16:26:58 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2014-02-02 18:09:06 -0400 |
commit | 43082dffefead64234f77d2a0cf29554ce9b2b29 (patch) | |
tree | 889b4a8542d4ca5a5d20cf1c650d1f79d0b1df56 /mail/src/leap | |
parent | 57b276b6651a5634f025e8ab99f2bdac24b8b336 (diff) |
re-add expunge deferred
Diffstat (limited to 'mail/src/leap')
-rw-r--r-- | mail/src/leap/mail/imap/mailbox.py | 20 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/memorystore.py | 10 |
2 files changed, 17 insertions, 13 deletions
diff --git a/mail/src/leap/mail/imap/mailbox.py b/mail/src/leap/mail/imap/mailbox.py index 688f941..40d3420 100644 --- a/mail/src/leap/mail/imap/mailbox.py +++ b/mail/src/leap/mail/imap/mailbox.py @@ -486,8 +486,8 @@ class SoledadMailbox(WithMsgFields, MBoxParser): Expunge and mark as closed """ d = self.expunge() - #d.addCallback(self._close_cb) - #return d + d.addCallback(self._close_cb) + return d def _expunge_cb(self, result): return result @@ -498,15 +498,11 @@ class SoledadMailbox(WithMsgFields, MBoxParser): """ if not self.isWriteable(): raise imap4.ReadOnlyMailbox - - return self._memstore.expunge(self.mbox) - - # TODO we can defer this back when it's correct - # but we should make sure the memstore has been synced. - - #d = self._memstore.expunge(self.mbox) - #d.addCallback(self._expunge_cb) - #return d + d = defer.Deferred() + return self._memstore.expunge(self.mbox, d) + self._memstore.expunge(self.mbox) + d.addCallback(self._expunge_cb, d) + return d def _bound_seq(self, messages_asked): """ @@ -800,7 +796,7 @@ class SoledadMailbox(WithMsgFields, MBoxParser): :rtype: Deferred """ from twisted.internet import reactor - print "COPY :", message + d = defer.Deferred() # XXX this should not happen ... track it down, # probably to FETCH... diff --git a/mail/src/leap/mail/imap/memorystore.py b/mail/src/leap/mail/imap/memorystore.py index 542e227..0632d1c 100644 --- a/mail/src/leap/mail/imap/memorystore.py +++ b/mail/src/leap/mail/imap/memorystore.py @@ -873,13 +873,15 @@ class MemoryStore(object): self.remove_message(mbox, uid) return mem_deleted - def expunge(self, mbox): + def expunge(self, mbox, observer): """ Remove all messages flagged \\Deleted, from the Memory Store and from the permanent store also. :param mbox: the mailbox :type mbox: str or unicode + :param observer: a deferred that will be fired when expunge is done + :type observer: Deferred :return: a list of UIDs :rtype: list """ @@ -910,6 +912,11 @@ class MemoryStore(object): else: sol_deleted = [] + try: + self._known_uids[mbox].difference_update(set(sol_deleted)) + except Exception as exc: + logger.exception(exc) + # 2. Delete all messages marked as deleted in memory. mem_deleted = self.remove_all_deleted(mbox) @@ -919,6 +926,7 @@ class MemoryStore(object): logger.exception(exc) finally: self._start_write_loop() + observer.callback(True) return all_deleted # Dump-to-disk controls. |