From 28556a0c377a238b3d7e599571d3ebbe15744e08 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Mon, 7 Apr 2014 19:42:54 -0700 Subject: [PATCH] catch ReadError when calling item.read() --- beets/autotag/__init__.py | 4 ++++ beets/ui/commands.py | 4 ++-- docs/changelog.rst | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/beets/autotag/__init__.py b/beets/autotag/__init__.py index 6b0c1185c..9001c295d 100644 --- a/beets/autotag/__init__.py +++ b/beets/autotag/__init__.py @@ -58,6 +58,10 @@ def albums_in_dir(path): log.warn(u'unreadable file: {0}'.format( displayable_path(filename)) ) + except library.ReadError as exc: + log.error(u'error reading {0}: {1}'.format( + displayable_path(filename), exc + )) else: items.append(i) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 5aadfdca4..08ffa394e 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -903,7 +903,7 @@ def update_items(lib, query, album, move, pretend): # Read new data. try: item.read() - except Exception as exc: + except library.ReadError as exc: log.error(u'error reading {0}: {1}'.format( displayable_path(item.path), exc)) continue @@ -1238,7 +1238,7 @@ def write_items(lib, query, pretend): # Get an Item object reflecting the "clean" (on-disk) state. try: clean_item = library.Item.from_path(item.path) - except Exception as exc: + except library.ReadError as exc: log.error(u'error reading {0}: {1}'.format( displayable_path(item.path), exc )) diff --git a/docs/changelog.rst b/docs/changelog.rst index dc7f562b4..ea868243c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -17,6 +17,8 @@ Fixes: content type. Thanks to Lee Reinhardt. * :doc:`/plugins/convert`: The ``--keep-new`` flag now works correctly 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. 1.3.4 (April 5, 2014)