Fix cover handling in device drivers

This commit is contained in:
Kovid Goyal 2010-01-01 11:26:30 -07:00
parent 22f0d6908c
commit 5e3cb90b12
3 changed files with 8 additions and 6 deletions

View file

@ -275,7 +275,7 @@ def upload_books(self, files, names, on_card=None, end_session=True,
:metadata: If not None, it is a list of :class:`MetaInformation` objects.
The idea is to use the metadata to determine where on the device to
put the book. len(metadata) == len(files). Apart from the regular
cover_data, there may also be a thumbnail attribute, which should
cover (path to cover), there may also be a thumbnail attribute, which should
be used in preference. The thumbnail attribute is of the form
(width, height, cover_data as jpeg). In addition the MetaInformation
objects can have a tag_order attribute.

View file

@ -715,8 +715,9 @@ def sync_news(self, send_ids=None, do_auto_convert=True):
prefix = ascii_filename(prefix)
names.append('%s_%d%s'%(prefix, id,
os.path.splitext(f.name)[1]))
if mi.cover_data and mi.cover_data[1]:
mi.thumbnail = self.cover_to_thumbnail(mi.cover_data[1])
if mi.cover and os.path.access(mi.cover, os.R_OK):
mi.thumbnail = self.cover_to_thumbnail(open(mi.cover,
'rb').read())
dynamic.set('news_to_be_synced', set([]))
if config['upload_news_to_device'] and files:
remove = ids if \
@ -751,8 +752,9 @@ def sync_to_device(self, on_card, delete_from_library,
metadata = self.library_view.model().metadata_for(ids)
ids = iter(ids)
for mi in metadata:
if mi.cover_data and mi.cover_data[1]:
mi.thumbnail = self.cover_to_thumbnail(mi.cover_data[1])
if mi.cover and os.path.access(mi.cover, os.R_OK):
mi.thumbnail = self.cover_to_thumbnail(open(mi.cover,
'rb').read())
imetadata = iter(metadata)
files = [getattr(f, 'name', None) for f in _files]

View file

@ -405,7 +405,7 @@ def metadata_for(self, ids):
mi = self.db.get_metadata(id, index_is_id=True)
if mi.series is not None:
mi.tag_order = { mi.series: self.db.books_in_series_of(id,
index_is_id=True)}
index_is_id=True, get_cover=True)}
ans.append(mi)
return ans