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

Conversation

pierreay
Copy link

Description

My library is managed using Beets for organization and git-annex as storage backend. Therefore when using this system, while my library files always exists on my filesystem, some files may be empty (without content). In this case, when I'm running the convert plugin, I don't wants it to process files which are empty (same apply for any Beets plugin). Hence, I added a check that the file is readable as a MediaFile before doing any process.

Before this fix, trying to encode an empty file would have lead to an error while leaving convert doing its side-effects and convert would also copy empty files to destination for files that doesn't need to be re-encoded.

In my case, this is empty files, but the problem can be anything else (depending on the storage backend) and/or corrupted files. Conclusion, I think checking that the file is readable is always recommended before proceeding to heavy operation like this.

To Do

  • Documentation. (If you've added a new command-line flag, for example, find the appropriate page under docs/ to describe it.)
  • Changelog. (Add an entry to docs/changelog.rst to the bottom of one of the lists near the top of the document.)
  • Tests. (Very much encouraged but not strictly required.)

beetsplug/convert.py Outdated Show resolved Hide resolved
@pierreay pierreay requested a review from Serene-Arc July 3, 2024 10:29
@pierreay pierreay force-pushed the pr-fix-convert-not-mediafile branch from a939053 to 01f39fb Compare July 3, 2024 10:35
@pierreay pierreay force-pushed the pr-fix-convert-not-mediafile branch from 01f39fb to e773368 Compare July 3, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants