newdb: Do not error out if the db contains null entries in the authors table

This commit is contained in:
Kovid Goyal 2013-08-30 08:27:28 +05:30
parent 6908eea3e9
commit e933f57798

View File

@ -1289,11 +1289,15 @@ class Cache(object):
string. '''
table = self.fields['authors'].table
result = []
try:
rmap = {icu_lower(v):k for k, v in table.id_map.iteritems()}
except AttributeError:
# Somehow, the authors table has some authors that are None. Corrupted db?
rmap = {icu_lower(v or ''):k for k, v in table.id_map.iteritems()}
for aut in authors:
aid = rmap.get(icu_lower(aut), None)
result.append(author_to_author_sort(aut) if aid is None else table.asort_map[aid])
return ' & '.join(result)
return ' & '.join(filter(None, result))
@read_api
def has_book(self, mi):