summaryrefslogtreecommitdiff
path: root/src/leap/mail/imap/memorystore.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-02-07 07:27:38 -0400
committerKali Kaneko <kali@leap.se>2014-02-17 11:39:48 -0400
commit9ffcaa09c2d6a57f3f34350298eff8412b540bc9 (patch)
treeb5aca2af6ca1db592ea0cb9f2789fc3ffb27fc2a /src/leap/mail/imap/memorystore.py
parentce55f761a55f78cb122296e91686fa6fde8959b8 (diff)
defer_to_thread the bulk of write operations
and batch the notifications back to the memorystore, within the reactor thread.
Diffstat (limited to 'src/leap/mail/imap/memorystore.py')
-rw-r--r--src/leap/mail/imap/memorystore.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/leap/mail/imap/memorystore.py b/src/leap/mail/imap/memorystore.py
index ee3ee92..786a9c4 100644
--- a/src/leap/mail/imap/memorystore.py
+++ b/src/leap/mail/imap/memorystore.py
@@ -380,7 +380,7 @@ class MemoryStore(object):
if empty(doc_id):
fdoc = self._permanent_store.get_flags_doc(mbox, uid)
- if empty(fdoc.content):
+ if empty(fdoc) or empty(fdoc.content):
return None
doc_id = fdoc.doc_id
self._fdoc_id_store[mbox][uid] = doc_id
@@ -706,9 +706,10 @@ class MemoryStore(object):
:rtype: iterable
"""
fdocs = self._fdoc_store[mbox]
+
return [uid for uid, value
in fdocs.items()
- if fields.SEEN_FLAG not in value["flags"]]
+ if fields.SEEN_FLAG not in value.get(fields.FLAGS_KEY, [])]
def get_cdoc_from_phash(self, phash):
"""
@@ -760,7 +761,7 @@ class MemoryStore(object):
# We want to create a new one in this case.
# Hmmm what if the deletion is un-done?? We would end with a
# duplicate...
- if fdoc and fields.DELETED_FLAG in fdoc[fields.FLAGS_KEY]:
+ if fdoc and fields.DELETED_FLAG in fdoc.get(fields.FLAGS_KEY, []):
return None
uid = fdoc[fields.UID_KEY]
@@ -810,7 +811,7 @@ class MemoryStore(object):
fdocs = self._fdoc_store[mbox]
return [uid for uid, value
in fdocs.items()
- if fields.DELETED_FLAG in value["flags"]]
+ if fields.DELETED_FLAG in value.get(fields.FLAGS_KEY, [])]
# new, dirty flags