summaryrefslogtreecommitdiff
path: root/src/leap/mail/imap/mailbox.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/mailbox.py
parent75da338c765ffb935290f5ca16ea2df406dc89d8 (diff)
prime-uids
We pre-fetch the uids from soledad on mailbox initialization
Diffstat (limited to 'src/leap/mail/imap/mailbox.py')
-rw-r--r--src/leap/mail/imap/mailbox.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/leap/mail/imap/mailbox.py b/src/leap/mail/imap/mailbox.py
index 6c8d78d..802ebf3 100644
--- a/src/leap/mail/imap/mailbox.py
+++ b/src/leap/mail/imap/mailbox.py
@@ -126,6 +126,7 @@ class SoledadMailbox(WithMsgFields, MBoxParser):
self.setFlags(self.INIT_FLAGS)
if self._memstore:
+ self.prime_known_uids_to_memstore()
self.prime_last_uid_to_memstore()
@property
@@ -263,10 +264,19 @@ class SoledadMailbox(WithMsgFields, MBoxParser):
Prime memstore with last_uid value
"""
set_exist = set(self.messages.all_uid_iter())
- last = max(set_exist) + 1 if set_exist else 1
+ last = max(set_exist) if set_exist else 0
logger.info("Priming Soledad last_uid to %s" % (last,))
self._memstore.set_last_soledad_uid(self.mbox, last)
+ def prime_known_uids_to_memstore(self):
+ """
+ Prime memstore with the set of all known uids.
+
+ We do this to be able to filter the requests efficiently.
+ """
+ known_uids = self.messages.all_soledad_uid_iter()
+ self._memstore.set_known_uids(self.mbox, known_uids)
+
def getUIDValidity(self):
"""
Return the unique validity identifier for this mailbox.
@@ -525,6 +535,7 @@ class SoledadMailbox(WithMsgFields, MBoxParser):
return seq_messg
@deferred
+ #@profile
def fetch(self, messages_asked, uid):
"""
Retrieve one or more messages in this mailbox.