mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
newdb: Handle damaged one-one text tables
Ignore text records in the database that are damaged, instead of erroring out. Lets the rest of the data be used. Fixes #1215981 [calibre 1.0 can't find database](https://bugs.launchpad.net/calibre/+bug/1215981)
This commit is contained in:
parent
4daace5860
commit
14b348b391
@ -92,7 +92,14 @@ class OneToOneTable(Table):
|
||||
query = db.conn.execute('SELECT {0}, {1} FROM {2}'.format(idcol,
|
||||
self.metadata['column'], self.metadata['table']))
|
||||
if self.unserialize is None:
|
||||
try:
|
||||
self.book_col_map = dict(query)
|
||||
except UnicodeDecodeError:
|
||||
# The db is damaged, try to work around it by ignoring
|
||||
# failures to decode utf-8
|
||||
query = db.conn.execute('SELECT {0}, cast({1} as blob) FROM {2}'.format(idcol,
|
||||
self.metadata['column'], self.metadata['table']))
|
||||
self.book_col_map = {k:bytes(val).decode('utf-8', 'ignore') for k, val in query}
|
||||
else:
|
||||
us = self.unserialize
|
||||
self.book_col_map = {book_id:us(val) for book_id, val in query}
|
||||
|
Loading…
x
Reference in New Issue
Block a user