mirror of
https://github.com/beetbox/beets.git
synced 2026-01-03 06:22:48 +01:00
log a warning instead of silently ignoring corrupt files
This commit is contained in:
parent
40a965ea18
commit
4dcbb38d78
3 changed files with 14 additions and 6 deletions
2
NEWS
2
NEWS
|
|
@ -14,6 +14,8 @@
|
|||
support UTF-8.
|
||||
* Importing without autotagging ("beet import -A") is now faster and
|
||||
doesn't print out a bunch of whitespace.
|
||||
* The importer now logs an error instead of crashing when it attempts
|
||||
to read a corrupt file.
|
||||
|
||||
1.0b1
|
||||
-----
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ from beets.autotag import mb
|
|||
import re
|
||||
from munkres import Munkres
|
||||
from beets import library, mediafile
|
||||
import logging
|
||||
|
||||
# Try 5 releases. In the future, this should be more dynamic: let the
|
||||
# probability of continuing to the next release be inversely
|
||||
|
|
@ -62,6 +63,9 @@ class AutotagError(Exception):
|
|||
class InsufficientMetadataError(AutotagError):
|
||||
pass
|
||||
|
||||
# Global logger.
|
||||
log = logging.getLogger('beets')
|
||||
|
||||
def _first_n(it, n):
|
||||
"""Takes an iterator and returns another iterator, trunacted to
|
||||
yield only the first n elements.
|
||||
|
|
@ -112,8 +116,7 @@ def albums_in_dir(path):
|
|||
except mediafile.FileTypeError:
|
||||
pass
|
||||
except mediafile.UnreadableFileError:
|
||||
#FIXME log an error
|
||||
pass
|
||||
log.warn('unreadable file: ' + filename)
|
||||
else:
|
||||
items.append(i)
|
||||
|
||||
|
|
|
|||
11
beets/ui.py
11
beets/ui.py
|
|
@ -18,9 +18,12 @@ import locale
|
|||
|
||||
from beets import autotag
|
||||
from beets import library
|
||||
from beets.mediafile import FileTypeError
|
||||
from beets.mediafile import UnreadableFileError, FileTypeError
|
||||
from beets.player import bpd
|
||||
|
||||
# Global logger.
|
||||
log = logging.getLogger('beets')
|
||||
|
||||
# Utilities.
|
||||
|
||||
def _print(txt=''):
|
||||
|
|
@ -356,9 +359,9 @@ def import_files(lib, paths, copy=True, write=True, autot=True, logpath=None):
|
|||
item = library.Item.from_path(filepath)
|
||||
except FileTypeError:
|
||||
continue
|
||||
except mediafile.UnreadableFileError:
|
||||
#FIXME log an error
|
||||
pass
|
||||
except UnreadableFileError:
|
||||
log.warn('unreadable file: ' + filepath)
|
||||
continue
|
||||
|
||||
# Add the item to the library, copying if requested.
|
||||
if copy:
|
||||
|
|
|
|||
Loading…
Reference in a new issue