LocalStatusSQLite: labels: don't fail if database returns unexpected None value
This requires more researches. See https://github.com/OfflineIMAP/offlineimap/issues/103 . Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
ca06819e70
commit
efc4df1bd7
@ -203,7 +203,21 @@ class LocalStatusSQLiteFolder(BaseFolder):
|
||||
uid = row[0]
|
||||
self.messagelist[uid] = self.msglist_item_initializer(uid)
|
||||
flags = set(row[1])
|
||||
labels = set([lb.strip() for lb in row[3].split(',') if len(lb.strip()) > 0])
|
||||
try:
|
||||
labels = set([lb.strip() for lb in
|
||||
row[3].split(',') if len(lb.strip()) > 0])
|
||||
except AttributeError:
|
||||
# FIXME: This except clause was introduced because row[3] from
|
||||
# database can be found of unexpected type NoneType. See
|
||||
# https://github.com/OfflineIMAP/offlineimap/issues/103
|
||||
#
|
||||
# We are fixing the type here but this would require more
|
||||
# researches to find the true root cause. row[3] is expected to
|
||||
# be a (empty) string, not None.
|
||||
#
|
||||
# Also, since database might return None, we have to fix the
|
||||
# database, too.
|
||||
labels = set()
|
||||
self.messagelist[uid]['flags'] = flags
|
||||
self.messagelist[uid]['labels'] = labels
|
||||
self.messagelist[uid]['mtime'] = row[2]
|
||||
|
@ -208,7 +208,7 @@ class MappedIMAPFolder(IMAPFolder):
|
||||
if uid < 0:
|
||||
return uid
|
||||
|
||||
#if msg uid already exists, just modify the flags
|
||||
# If msg uid already exists, just modify the flags.
|
||||
if uid in self.r2l:
|
||||
self.savemessageflags(uid, flags)
|
||||
return uid
|
||||
@ -238,11 +238,10 @@ class MappedIMAPFolder(IMAPFolder):
|
||||
|
||||
# Interface from BaseFolder
|
||||
def savemessageflags(self, uid, flags):
|
||||
"""
|
||||
|
||||
Note that this function does not check against dryrun settings,
|
||||
"""Note that this function does not check against dryrun settings,
|
||||
so you need to ensure that it is never called in a
|
||||
dryrun mode."""
|
||||
|
||||
self._mb.savemessageflags(self.r2l[uid], flags)
|
||||
|
||||
# Interface from BaseFolder
|
||||
|
Loading…
Reference in New Issue
Block a user