don't crash when singleton-importing broken files

This commit is contained in:
Adrian Sampson 2012-12-08 12:10:06 -08:00
parent ae7b29b698
commit 98892945c2
2 changed files with 9 additions and 1 deletions

View file

@ -29,6 +29,7 @@ from beets import util
from beets.util import pipeline
from beets.util import syspath, normpath, displayable_path
from beets.util.enumeration import enum
from beets.mediafile import UnreadableFileError
action = enum(
'SKIP', 'ASIS', 'TRACKS', 'MANUAL', 'APPLY', 'MANUAL_ID',
@ -485,7 +486,13 @@ def read_tasks(config):
for toppath in config.paths:
# Check whether the path is to a file.
if config.singletons and not os.path.isdir(syspath(toppath)):
item = library.Item.from_path(toppath)
try:
item = library.Item.from_path(toppath)
except UnreadableFileError:
log.warn(u'unreadable file: {0}'.format(
util.displayable_path(toppath)
))
continue
yield ImportTask.item_task(item)
continue

View file

@ -80,6 +80,7 @@ Changelog
names in their path.
* Fix a crash when Unicode queries were used with ``import -L`` re-imports.
* Fix an error when fingerprinting files with Unicode filenames on Windows.
* Warn instead of crashing when importing a specific file in singleton mode.
* Add human-readable error messages when writing files' tags fails or when a
directory can't be created.
* Changed plugin loading so that modules can be imported without