diff options
author | Kali Kaneko <kali@leap.se> | 2013-12-20 16:36:21 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2013-12-20 16:36:39 -0400 |
commit | ee1fa7da3bdc2de2bd12c55a4da9ccc291d3e82c (patch) | |
tree | 97ec52ca44538623847f20e3fede229d9876aa9c /src | |
parent | 9460ea1bb8fd7e536aa3dcf3ed746e3765c96fa1 (diff) |
safety catch against wrong last_uid
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/mail/imap/server.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/leap/mail/imap/server.py b/src/leap/mail/imap/server.py index f77bf2c..d92ab9d 100644 --- a/src/leap/mail/imap/server.py +++ b/src/leap/mail/imap/server.py @@ -1430,7 +1430,22 @@ class SoledadMailbox(WithMsgFields): leap_assert(isinstance(uid, int), "uid has to be int") mbox = self._get_mbox() key = self.LAST_UID_KEY - mbox.content[key] = uid + + count = mbox.getMessageCount() + + # XXX safety-catch. If we do get duplicates, + # we want to avoid further duplication. + + if uid >= count: + value = uid + else: + # something is wrong, + # just set the last uid + # beyond the max msg count. + logger.debug("WRONG uid < count. Setting last uid to ", count) + value = count + + mbox.content[key] = value self._soledad.put_doc(mbox) last_uid = property( |