Skip to content

Commit 89bb4f8

Browse files
committed
Use new format in determining destination.
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.
1 parent becb073 commit 89bb4f8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

beetsplug/convert.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,12 @@ def convert_item(
355355
item, original, converted = None, None, None
356356
while True:
357357
item = yield (item, original, converted)
358+
# item format should represent the converted format, not the original
359+
original_format, new_format = item.format, fmt.upper()
360+
item.format = new_format
358361
dest = item.destination(basedir=dest_dir, path_formats=path_formats)
359-
362+
# need to restore this attribute for checks further along
363+
item.format = original_format
360364
# Ensure that desired item is readable before processing it. Needed
361365
# to avoid any side-effect of the conversion (linking, keep_new,
362366
# refresh) if we already know that it will fail.

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Bug fixes:
3030

3131
- |BeetsPlugin|: load the last plugin class defined in the plugin namespace.
3232
:bug:`6093`
33+
- Fixed convert plugin not taking into account the new format when determining
34+
the target path. :bug:`1360`
3335

3436
For packagers:
3537

0 commit comments

Comments
 (0)