From e7a2e303aaa74fc0b238a84972f023c7df3c4ed9 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Thu, 26 Feb 2015 13:04:30 -0400 Subject: [bug] increment: avoid TypeError when there's no entries in table --- mail/src/leap/mail/mailbox_indexer.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'mail/src/leap') diff --git a/mail/src/leap/mail/mailbox_indexer.py b/mail/src/leap/mail/mailbox_indexer.py index 732a6eeb..664d5804 100644 --- a/mail/src/leap/mail/mailbox_indexer.py +++ b/mail/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) -- cgit v1.2.3