Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix convert plugin attempting to process a non-media file #5261

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions beetsplug/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -346,6 +347,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.
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,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:

Expand Down
Loading