embedart: catch log errors (fix #678)

This commit is contained in:
Adrian Sampson 2014-04-10 11:24:59 -07:00
parent db7588021b
commit 33b44717ab
2 changed files with 8 additions and 2 deletions

View file

@ -32,7 +32,12 @@ def _embed(path, items, maxwidth=0):
if maxwidth:
path = ArtResizer.shared.resize(maxwidth, syspath(path))
data = open(syspath(path), 'rb').read()
try:
with open(syspath(path), 'rb') as f:
data = f.read()
except IOError as exc:
log.error(u'embedart: could not read image file: {0}'.format(exc))
return
image = mediafile.Image(data, type=mediafile.ImageType.front)
# Add art to each file.
@ -41,7 +46,7 @@ def _embed(path, items, maxwidth=0):
for item in items:
try:
f = mediafile.MediaFile(syspath(item.path))
except mediafile.UnreadableFileError as exc:
except (mediafile.UnreadableFileError, IOError) as exc:
log.warn('Could not embed art in {0}: {1}'.format(
displayable_path(item.path), exc
))

View file

@ -22,6 +22,7 @@ Fixes:
and the library includes the converted item.
* The importer now logs a message instead of crashing when errors occur while
opening the files to be imported.
* :doc:`/plugins/embedart`: Better error messages in exceptional conditions.
.. _enum34: https://pypi.python.org/pypi/enum34
.. _enum: https://docs.python.org/3.4/library/enum.html