diff options
| author | Kali Kaneko <kali@leap.se> | 2014-02-06 15:46:17 -0400 | 
|---|---|---|
| committer | Kali Kaneko <kali@leap.se> | 2014-02-17 11:37:03 -0400 | 
| commit | 38850041e740a9a5becd8fa37d79c2b145a6d722 (patch) | |
| tree | e9d785034e7ee35b31f9c51a0026903950882318 | |
| parent | 49d4e76decd2166a602088b622e88b3812b26a68 (diff) | |
take recent count from memstore
| -rw-r--r-- | mail/src/leap/mail/imap/mailbox.py | 11 | ||||
| -rw-r--r-- | mail/src/leap/mail/imap/memorystore.py | 1 | ||||
| -rw-r--r-- | mail/src/leap/mail/imap/messages.py | 25 | ||||
| -rw-r--r-- | mail/src/leap/mail/imap/service/imap.py | 7 | ||||
| -rw-r--r-- | mail/src/leap/mail/imap/soledadstore.py | 19 | 
5 files changed, 35 insertions, 28 deletions
| diff --git a/mail/src/leap/mail/imap/mailbox.py b/mail/src/leap/mail/imap/mailbox.py index 1fa05542..c188f919 100644 --- a/mail/src/leap/mail/imap/mailbox.py +++ b/mail/src/leap/mail/imap/mailbox.py @@ -559,6 +559,7 @@ class SoledadMailbox(WithMsgFields, MBoxParser):          :rtype: A tuple of two-tuples of message sequence numbers and                  LeapMessage          """ +        from twisted.internet import reactor          # For the moment our UID is sequential, so we          # can treat them all the same.          # Change this to the flag that twisted expects when we @@ -577,6 +578,7 @@ class SoledadMailbox(WithMsgFields, MBoxParser):              raise NotImplementedError          else:              result = ((msgid, getmsg(msgid)) for msgid in seq_messg) +            reactor.callLater(0, self.unset_recent_flags, seq_messg)          return result      def fetch_flags(self, messages_asked, uid): @@ -838,6 +840,10 @@ class SoledadMailbox(WithMsgFields, MBoxParser):                  new_fdoc[self.UID_KEY] = uid_next                  new_fdoc[self.MBOX_KEY] = mbox +                flags = list(new_fdoc[self.FLAGS_KEY]) +                flags.append(fields.RECENT_FLAG) +                new_fdoc[self.FLAGS_KEY] = flags +                  # FIXME set recent!                  self._memstore.create_message( @@ -890,12 +896,11 @@ class SoledadMailbox(WithMsgFields, MBoxParser):          for doc in docs:              self.messages._soledad.delete_doc(doc) -    def unset_recent_flags(self, uids): +    def unset_recent_flags(self, uid_seq):          """          Unset Recent flag for a sequence of UIDs.          """ -        seq_messg = self._bound_seq(uids) -        self.messages.unset_recent_flags(seq_messg) +        self.messages.unset_recent_flags(uid_seq)      def __repr__(self):          """ diff --git a/mail/src/leap/mail/imap/memorystore.py b/mail/src/leap/mail/imap/memorystore.py index 00cf2cce..bc40a8e1 100644 --- a/mail/src/leap/mail/imap/memorystore.py +++ b/mail/src/leap/mail/imap/memorystore.py @@ -827,7 +827,6 @@ class MemoryStore(object):      # Recent Flags -    # TODO --- nice but unused      def set_recent_flag(self, mbox, uid):          """          Set the `Recent` flag for a given mailbox and UID. diff --git a/mail/src/leap/mail/imap/messages.py b/mail/src/leap/mail/imap/messages.py index 3ba9d1b6..cfad1dc4 100644 --- a/mail/src/leap/mail/imap/messages.py +++ b/mail/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):          """ diff --git a/mail/src/leap/mail/imap/service/imap.py b/mail/src/leap/mail/imap/service/imap.py index 93df51d1..726049c3 100644 --- a/mail/src/leap/mail/imap/service/imap.py +++ b/mail/src/leap/mail/imap/service/imap.py @@ -115,7 +115,12 @@ class LeapIMAPFactory(ServerFactory):          # XXX how to pass the store along?      def buildProtocol(self, addr): -        "Return a protocol suitable for the job." +        """ +        Return a protocol suitable for the job. + +        :param addr: ??? +        :type addr:  ??? +        """          imapProtocol = LeapIMAPServer(              uuid=self._uuid,              userid=self._userid, diff --git a/mail/src/leap/mail/imap/soledadstore.py b/mail/src/leap/mail/imap/soledadstore.py index 3c0b6f94..a74b49c0 100644 --- a/mail/src/leap/mail/imap/soledadstore.py +++ b/mail/src/leap/mail/imap/soledadstore.py @@ -86,10 +86,12 @@ class ContentDedup(object):          if not header_docs:              return False -        if len(header_docs) != 1: -            logger.warning("Found more than one copy of chash %s!" -                           % (chash,)) -        logger.debug("Found header doc with that hash! Skipping save!") +        # FIXME enable only to debug this problem. +        #if len(header_docs) != 1: +            #logger.warning("Found more than one copy of chash %s!" +                           #% (chash,)) + +        #logger.debug("Found header doc with that hash! Skipping save!")          return True      def _content_does_exist(self, doc): @@ -110,10 +112,11 @@ class ContentDedup(object):          if not attach_docs:              return False -        if len(attach_docs) != 1: -            logger.warning("Found more than one copy of phash %s!" -                           % (phash,)) -        logger.debug("Found attachment doc with that hash! Skipping save!") +        # FIXME enable only to debug this problem +        #if len(attach_docs) != 1: +            #logger.warning("Found more than one copy of phash %s!" +                           #% (phash,)) +        #logger.debug("Found attachment doc with that hash! Skipping save!")          return True | 
