summaryrefslogtreecommitdiff
path: root/src/leap/mail/imap/messages.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-02-06 15:46:17 -0400
committerKali Kaneko <kali@leap.se>2014-02-17 11:37:03 -0400
commitff3a6a640fdb345449a5f9cd3379bbaefa36111e (patch)
tree6204ca56079c0cbd0dbce5855f0e4d5ab1dfa09e /src/leap/mail/imap/messages.py
parentb7d28d1ee8208e1361caa73740d826af3b4c572e (diff)
take recent count from memstore
Diffstat (limited to 'src/leap/mail/imap/messages.py')
-rw-r--r--src/leap/mail/imap/messages.py25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/leap/mail/imap/messages.py b/src/leap/mail/imap/messages.py
index 3ba9d1b..cfad1dc 100644
--- a/src/leap/mail/imap/messages.py
+++ b/src/leap/mail/imap/messages.py
@@ -1265,6 +1265,7 @@ class MessageCollection(WithMsgFields, IndexedDB, MailParser, MBoxParser):
#fields.TYPE_FLAGS_VAL, self.mbox)))
#return all_flags_chash
+ # XXX get from memstore
def all_headers(self):
"""
Return a dict with all the headers documents for this
@@ -1282,13 +1283,10 @@ class MessageCollection(WithMsgFields, IndexedDB, MailParser, MBoxParser):
:rtype: int
"""
- # XXX We should cache this in memstore too until next write...
- count = self._soledad.get_count_from_index(
- fields.TYPE_MBOX_IDX,
- fields.TYPE_FLAGS_VAL, self.mbox)
- if self.memstore is not None:
- count += self.memstore.count_new()
- return count
+ # XXX get this from a public method in memstore
+ store = self.memstore._msg_store
+ return len([uid for (mbox, uid) in store.keys()
+ if mbox == self.mbox])
# unseen messages
@@ -1300,10 +1298,10 @@ class MessageCollection(WithMsgFields, IndexedDB, MailParser, MBoxParser):
:return: iterator through unseen message doc UIDs
:rtype: iterable
"""
- return (doc.content[self.UID_KEY] for doc in
- self._soledad.get_from_index(
- fields.TYPE_MBOX_SEEN_IDX,
- fields.TYPE_FLAGS_VAL, self.mbox, '0'))
+ # XXX get this from a public method in memstore
+ store = self.memstore._msg_store
+ return (uid for (mbox, uid), d in store.items()
+ if mbox == self.mbox and "\\Seen" not in d["fdoc"]["flags"])
def count_unseen(self):
"""
@@ -1312,10 +1310,7 @@ class MessageCollection(WithMsgFields, IndexedDB, MailParser, MBoxParser):
:returns: count
:rtype: int
"""
- count = self._soledad.get_count_from_index(
- fields.TYPE_MBOX_SEEN_IDX,
- fields.TYPE_FLAGS_VAL, self.mbox, '0')
- return count
+ return len(list(self.unseen_iter()))
def get_unseen(self):
"""