-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Have convert use the new format when deciding path #6105
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
base: master
Are you sure you want to change the base?
Have convert use the new format when deciding path #6105
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3e0dc73 to
d411a83
Compare
|
Seeing as there are test failures here, and the tests seem to be checking for (what I would consider to be) the wrong output path, I would love some guidance on how to handle this from a maintainer. Should I change the tests, mark those texts as |
henry-oberholtzer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely a feature I'd like to see implemented.
I think right now the logic isn't quite placed where it needs to be - overriding the item's format definitely seems like the quickest way to hack it to the right path, but I think we're seeing a lot of unintended side-effects from it in the amount of tests that are currently failing. I've left a comment indicating what I think might be causing it, and a potential workarounds.
Appreciate the comment, I'm happy to keep working to the point that it's ready to be merged. |
d411a83 to
c72d320
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where the convert plugin was using the original file format instead of the target format when determining the destination path for converted files. The fix ensures that the new format is considered when calculating the destination path.
- Temporarily overrides the item's format attribute before calling
destination()to generate a path that reflects the target format - Restores the original format attribute after path calculation to maintain expected behavior in subsequent operations
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| docs/changelog.rst | Added changelog entry documenting the bug fix for issue #1360 |
| beetsplug/convert.py | Modified convert_item to temporarily override item format when calculating destination path |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
beetsplug/convert.py
Outdated
| original_format, new_format = item.format(), fmt.uppre() | ||
| item.format = new_format |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directly mutating the item's format attribute is fragile and could cause issues if an exception occurs before restoration. Consider using a context manager or try/finally block to ensure the format is always restored, even if an error occurs during destination calculation.
c72d320 to
89bb4f8
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6105 +/- ##
=======================================
Coverage 67.46% 67.46%
=======================================
Files 136 136
Lines 18535 18538 +3
Branches 3130 3130
=======================================
+ Hits 12504 12507 +3
Misses 5366 5366
Partials 665 665
🚀 New features to boost your workflow:
|
When figuring out what the filepath should be for the converted file, we temporarily change the item format to represent the format of the converted file. After determining what the path is, we restore the format attribute so the rest of the codepath logic checks out.
89bb4f8 to
aa9574b
Compare
By overriding the format attribute of the item, beets comes up with a destination path that the user expects.
Description
Fixes #1360
Currently when doing a convert command, when beets determines what the new file path should be, it uses the path to the original file, and changes the extension, but the new format is not referenced at all when determining the new destination path. This PR overrides the format attribute of the item just before the destination path is resolved, thus returning the path that takes the new format in mind.
To Do
This is my first contribution to
beets(and frankly, the first time I've had reason to look at the codebase). There could very well be a relevant class method I missed to better accomplish what I want rather than overriding theformatattributedocs/to describe it.)docs/changelog.rstto the bottom of one of the lists near the top of the document.)