Why is moe copying extra files a second time, from the destination folder back to the destination folder? #280
Replies: 2 comments
-
What's happening is that moe is copying all items (albums, tracks, and extras) being added to the library, but when albums are copied, so are its underlying tracks and extras. So the added items list might look like:
First, it will copy So your custom function gets called a second time when moe reaches the extra for a second time and generates the final path it would copy the extra to, to check if it already exists there. The problem seems to be that your custom I do think this could be considered a bug, as we should allow custom path functions as you're attempting without having to worry about this edge case, so I'd like to see a fix within Moe itself. @moe.hookimpl(trylast=True)
def edit_new_items(items: list[LibItem]):
"""Copies and formats the path of an item after it has been added to the library."""
for item in items:
copy_item(item) If you're willing to give it a shot, I assume the fix would lie in the above function, to not call A workaround in the meantime for you may be to check if the album already exists at its final destination (call |
Beta Was this translation helpful? Give feedback.
-
Thanks for digging into this and explaining what's going on! What I'm seeing makes sense now. Not sure if there's a better way to organize/rename extras based on their extension, but it doesn't seem hard to fix this behavior.
Maybe I can sort |
Beta Was this translation helpful? Give feedback.
-
I'm not sure if this is actually a bug so I haven't opened a bug report (also not sure how to reproduce without the files, dummy files maybe?).
I'm trying to organize some extra files when I noticed that moe is copying the extra from the source directory to the destination directory in the library correctly, but then it moves it from the destination folder to the destination folder during which the name gets changed incorrectly.
I think the main issue is that I have a custom
extra_path
which seems to be evaluated twice?Here's my moe config: https://github.com/ali-ramadhan/moe-plugins/blob/main/moe_config.toml
Here's my
organize_extras
plugin: https://github.com/ali-ramadhan/moe-plugins/blob/main/organize_extras.pyI'll try to describe the issue in more detail below. Apologies for the long post!
Here's the source directory structure:
so I expect it to preserve the
scans
directory but here's what I end up with:Here's the log with
moe -v add
and I've added a print statement to show the result oforganize_extras(extra)
:So I notice that the function
organize_extras(extra)
is being called twice on each extra. Once when copying each track, then again when copying the album.And indeed when I print a stacktrace in
organize_extras
I see that in the second call the stacktrace is coming fromcopy_album
.Stacktrace from the first time
organize_extras
is called:Second time:
Beta Was this translation helpful? Give feedback.
All reactions