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 | 8201146254a204fec92395bf497a2a6f76274b85 (patch) | |
tree | 234697b9fac5b392953db47f5d421387d94687ce /src/leap/mail/imap | |
parent | 18fed49c4143eb764ae9e806882d24f8f4e95744 (diff) |
re-add expunge deferred
Diffstat (limited to 'src/leap/mail/imap')
-rw-r--r-- | src/leap/mail/imap/mailbox.py | 20 | ||||
-rw-r--r-- | src/leap/mail/imap/memorystore.py | 10 |
2 files changed, 17 insertions, 13 deletions
diff --git a/src/leap/mail/imap/mailbox.py b/src/leap/mail/imap/mailbox.py index 688f941..40d3420 100644 --- a/src/leap/mail/imap/mailbox.py +++ b/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/src/leap/mail/imap/memorystore.py b/src/leap/mail/imap/memorystore.py index 542e227..0632d1c 100644 --- a/src/leap/mail/imap/memorystore.py +++ b/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. |