summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2015-02-26 13:04:30 -0400
committerKali Kaneko <kali@leap.se>2015-03-03 14:26:32 -0400
commitf6375e6bed217974369d77b7ff7191c3cb9fbb24 (patch)
tree8f3d4b305e9844754ae590bb84c41614494c1447
parentc49b378efdf61b7f06f3596e6ecf4ac0d27128fa (diff)
[bug] increment: avoid TypeError when there's no entries in table
-rw-r--r--src/leap/mail/mailbox_indexer.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/leap/mail/mailbox_indexer.py b/src/leap/mail/mailbox_indexer.py
index 732a6ee..664d580 100644
--- a/src/leap/mail/mailbox_indexer.py
+++ b/src/leap/mail/mailbox_indexer.py
@@ -278,12 +278,8 @@ class MailboxIndexer(object):
:rtype: Deferred
"""
check_good_uuid(mailbox_uuid)
-
- def increment(result):
- return result + 1
-
d = self.get_last_uid(mailbox_uuid)
- d.addCallback(increment)
+ d.addCallback(lambda uid: uid + 1)
return d
def get_last_uid(self, mailbox_uuid):
@@ -296,7 +292,10 @@ class MailboxIndexer(object):
preffix=self.table_preffix, name=sanitize(mailbox_uuid))
def getit(result):
- return _maybe_first_query_item(result)
+ rowid = _maybe_first_query_item(result)
+ if not rowid:
+ rowid = 0
+ return rowid
d = self._query(sql)
d.addCallback(getit)