summaryrefslogtreecommitdiff
path: root/mail
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-02-12 12:37:31 -0400
committerKali Kaneko <kali@leap.se>2014-02-17 11:39:49 -0400
commit07ae83aba57072626c48edee7c101a2584d938d4 (patch)
treebaba087ab75a931e2c0d087742fb4be794fecc13 /mail
parent07e1b3faeb8ca6b3105f954e1dfd85ba9e43e6d8 (diff)
purge empty fdocs on select
Diffstat (limited to 'mail')
-rw-r--r--mail/src/leap/mail/imap/mailbox.py3
-rw-r--r--mail/src/leap/mail/imap/memorystore.py21
2 files changed, 24 insertions, 0 deletions
diff --git a/mail/src/leap/mail/imap/mailbox.py b/mail/src/leap/mail/imap/mailbox.py
index 70833167..087780f6 100644
--- a/mail/src/leap/mail/imap/mailbox.py
+++ b/mail/src/leap/mail/imap/mailbox.py
@@ -157,6 +157,9 @@ class SoledadMailbox(WithMsgFields, MBoxParser):
from twisted.internet import reactor
self.reactor = reactor
+ # purge memstore from empty fdocs.
+ self._memstore.purge_fdoc_store(mbox)
+
@property
def listeners(self):
"""
diff --git a/mail/src/leap/mail/imap/memorystore.py b/mail/src/leap/mail/imap/memorystore.py
index 423b8916..4aaee752 100644
--- a/mail/src/leap/mail/imap/memorystore.py
+++ b/mail/src/leap/mail/imap/memorystore.py
@@ -362,6 +362,27 @@ class MemoryStore(object):
self._sizes[key] = size.get_size(self._fdoc_store[key])
# TODO add hdoc and cdocs sizes too
+ def purge_fdoc_store(self, mbox):
+ """
+ Purge the empty documents from a fdoc store.
+ Called during initialization of the SoledadMailbox
+
+ :param mbox: the mailbox
+ :type mbox: str or unicode
+ """
+ # XXX This is really a workaround until I find the conditions
+ # that are making the empty items remain there.
+ # This happens, for instance, after running several times
+ # the regression test, that issues a store deleted + expunge + select
+ # The items are being correclty deleted, but in succesive appends
+ # the empty items with previously deleted uids reappear as empty
+ # documents. I suspect it's a timing condition with a previously
+ # evaluated sequence being used after the items has been removed.
+
+ for uid, value in self._fdoc_store[mbox].items():
+ if empty(value):
+ del self._fdoc_store[mbox][uid]
+
def get_docid_for_fdoc(self, mbox, uid):
"""
Return Soledad document id for the flags-doc for a given mbox and uid,