summaryrefslogtreecommitdiff
path: root/src/leap/mail/imap/memorystore.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-01-30 18:35:03 -0400
committerKali Kaneko <kali@leap.se>2014-01-31 02:12:02 -0400
commitff7de0c9bc760e097c0286d2d62a19095be3f35e (patch)
tree834ffdf4fa8bf6f79a2be4ebb5151f8d2b28feef /src/leap/mail/imap/memorystore.py
parent75da338c765ffb935290f5ca16ea2df406dc89d8 (diff)
prime-uids
We pre-fetch the uids from soledad on mailbox initialization
Diffstat (limited to 'src/leap/mail/imap/memorystore.py')
-rw-r--r--src/leap/mail/imap/memorystore.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/leap/mail/imap/memorystore.py b/src/leap/mail/imap/memorystore.py
index fac66ad..217ad8e 100644
--- a/src/leap/mail/imap/memorystore.py
+++ b/src/leap/mail/imap/memorystore.py
@@ -149,6 +149,14 @@ class MemoryStore(object):
"""
self._last_uid = {}
+ """
+ known-uids keeps a count of the uids that soledad knows for a given
+ mailbox
+
+ {'mbox-a': set([1,2,3])}
+ """
+ self._known_uids = defaultdict(set)
+
# New and dirty flags, to set MessageWrapper State.
self._new = set([])
self._new_deferreds = {}
@@ -447,10 +455,20 @@ class MemoryStore(object):
:param mbox: the mailbox
:type mbox: str or unicode
+ :rtype: list
"""
all_keys = self._msg_store.keys()
return [uid for m, uid in all_keys if m == mbox]
+ def get_soledad_known_uids(self, mbox):
+ """
+ Get all uids that soledad knows about, from the memory cache.
+ :param mbox: the mailbox
+ :type mbox: str or unicode
+ :rtype: list
+ """
+ return self._known_uids.get(mbox, [])
+
# last_uid
def get_last_uid(self, mbox):
@@ -496,6 +514,18 @@ class MemoryStore(object):
if not self._last_uid.get(mbox, None):
self._last_uid[mbox] = value
+ def set_known_uids(self, mbox, value):
+ """
+ Set the value fo the known-uids set for this mbox.
+
+ :param mbox: the mailbox
+ :type mbox: str or unicode
+ :param value: a sequence of integers to be added to the set.
+ :type value: tuple
+ """
+ current = self._known_uids[mbox]
+ self._known_uids[mbox] = current.union(set(value))
+
def increment_last_soledad_uid(self, mbox):
"""
Increment by one the soledad integer cache for the last_uid for