diff --git a/beetsplug/convert.py b/beetsplug/convert.py index 536acf16e3..0c50fc73fb 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -22,6 +22,7 @@ import threading from string import Template +import mediafile from confuse import ConfigTypeError, Optional from beets import art, config, plugins, ui, util @@ -351,6 +352,15 @@ def convert_item( item = yield (item, original, converted) dest = item.destination(basedir=dest_dir, path_formats=path_formats) + # Ensure that desired item is readable before processing it. Needed + # to avoid any side-effect of the conversion (linking, keep_new, + # refresh) if we already know that it will fail. + try: + mediafile.MediaFile(util.syspath(item.path)) + except mediafile.UnreadableFileError as exc: + self._log.error("Could not open file to convert: {0}", exc) + continue + # When keeping the new file in the library, we first move the # current (pristine) file to the destination. We'll then copy it # back to its old path or transcode it to a new path. diff --git a/docs/changelog.rst b/docs/changelog.rst index 43cdd12555..c5b26c2db4 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -519,6 +519,8 @@ Bug fixes: `requests` timeout. * Fix cover art resizing logic to support multiple steps of resizing :bug:`5151` +* :doc:`/plugins/convert`: Fix attempt to convert and perform side-effects if + library file is not readable. For plugin developers: