diff options
author | Kali Kaneko <kali@leap.se> | 2014-01-16 17:18:11 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2014-01-16 17:18:11 -0400 |
commit | cfe173321dfcf55da571d0e42f93680e4452b5c1 (patch) | |
tree | 5575c5702bdf92472224859781b42293440e9812 /mail/src | |
parent | b8f726fd579a826c0ba6cfc454ff9dc9dc6d95ef (diff) |
reset last uid on expunge
Diffstat (limited to 'mail/src')
-rw-r--r-- | mail/src/leap/mail/imap/mailbox.py | 1 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/messages.py | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/mail/src/leap/mail/imap/mailbox.py b/mail/src/leap/mail/imap/mailbox.py index 94070ac..86dac77 100644 --- a/mail/src/leap/mail/imap/mailbox.py +++ b/mail/src/leap/mail/imap/mailbox.py @@ -463,6 +463,7 @@ class SoledadMailbox(WithMsgFields, MBoxParser): if not self.isWriteable(): raise imap4.ReadOnlyMailbox d = self.messages.remove_all_deleted() + d.addCallback(self.messages.reset_last_uid) d.addCallback(self._expunge_cb) return d diff --git a/mail/src/leap/mail/imap/messages.py b/mail/src/leap/mail/imap/messages.py index 22de356..02df38e 100644 --- a/mail/src/leap/mail/imap/messages.py +++ b/mail/src/leap/mail/imap/messages.py @@ -1337,6 +1337,18 @@ class MessageCollection(WithMsgFields, IndexedDB, MailParser, MBoxParser, fields.TYPE_FLAGS_VAL, self.mbox)) return (u for u in sorted(all_uids)) + def reset_last_uid(self, param): + """ + Set the last uid to the highest uid found. + Used while expunging, passed as a callback. + """ + try: + self.last_uid = max(self.all_uid_iter()) + 1 + except ValueError: + # empty sequence + pass + return param + def all_flags(self): """ Return a dict with all flags documents for this mailbox. |