diff options
author | Kali Kaneko <kali@leap.se> | 2014-02-11 02:53:28 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2014-02-17 11:39:49 -0400 |
commit | fd9c8c2e3c88476b90805b689f6914fe5eac16df (patch) | |
tree | 36a7079f8f10d71d67abbb945612e1588864b922 /src/leap/mail/imap/memorystore.py | |
parent | 04dfa3afdbb2080c717bfd32d6e47641615967fc (diff) |
defer fetch to thread
also, dispatch query for all headers to its own method.
Diffstat (limited to 'src/leap/mail/imap/memorystore.py')
-rw-r--r-- | src/leap/mail/imap/memorystore.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/leap/mail/imap/memorystore.py b/src/leap/mail/imap/memorystore.py index 2835826..e8e8152 100644 --- a/src/leap/mail/imap/memorystore.py +++ b/src/leap/mail/imap/memorystore.py @@ -434,6 +434,8 @@ class MemoryStore(object): hdoc = self._hdoc_store[chash] if empty(hdoc): hdoc = self._permanent_store.get_headers_doc(chash) + if empty(hdoc): + return None if not empty(hdoc.content): self._hdoc_store[chash] = hdoc.content hdoc = hdoc.content @@ -699,6 +701,31 @@ class MemoryStore(object): continue return flags_dict + def all_headers(self, mbox): + """ + Return a dictionary with all the header docs for a given mbox. + + :param mbox: the mailbox + :type mbox: str or unicode + :rtype: dict + """ + headers_dict = {} + uids = self.get_uids(mbox) + fdoc_store = self._fdoc_store[mbox] + hdoc_store = self._hdoc_store + + for uid in uids: + try: + chash = fdoc_store[uid][fields.CONTENT_HASH_KEY] + hdoc = hdoc_store[chash] + if not empty(hdoc): + headers_dict[uid] = hdoc + except KeyError: + continue + + import pprint; pprint.pprint(headers_dict) + return headers_dict + # Counting sheeps... def count_new_mbox(self, mbox): |