Fix for mysterious database entries without paths (corrupt db?)

This commit is contained in:
Kovid Goyal 2014-02-11 19:14:58 +05:30
parent 4d9eb2710f
commit 992070d587

View File

@ -1254,7 +1254,14 @@ class Cache(object):
if name and not replace: if name and not replace:
return False return False
path = self._field_for('path', book_id).replace('/', os.sep) path = self._field_for('path', book_id)
if path is None:
# Theoretically, this should never happen, but apparently it
# does: http://www.mobileread.com/forums/showthread.php?t=233353
self._update_path({book_id}, mark_as_dirtied=False)
path = self._field_for('path', book_id)
path = path.replace('/', os.sep)
title = self._field_for('title', book_id, default_value=_('Unknown')) title = self._field_for('title', book_id, default_value=_('Unknown'))
author = self._field_for('authors', book_id, default_value=(_('Unknown'),))[0] author = self._field_for('authors', book_id, default_value=(_('Unknown'),))[0]
stream = stream_or_path if hasattr(stream_or_path, 'read') else lopen(stream_or_path, 'rb') stream = stream_or_path if hasattr(stream_or_path, 'read') else lopen(stream_or_path, 'rb')