-
-
Notifications
You must be signed in to change notification settings - Fork 424
PICARD-3133: Adds a file presave hook #2757
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?
Conversation
|
Please search (or create) a matching ticket (and prefix title with the ticket number, PICARD-XXXX: ) |
…d into feature/file_hook_presave
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.
Code looks clean, thanks.
My issue with this is that such a hook can modify the metadata and hence something different will be saved then originally shown in the UI.
There might be some use cases for this, but we should be extremely careful with plugins making use of this hook. There must be a real need for what the plugin does. If the result is doable by other hooks those must be preferred.
I think most use cases, including the one in your ticket about different format metadata, can be handled by file_post_addition_to_track_processor.
A real use case is the sidecar files I think.
|
@phw If my use case could be handled by those other hooks, I wouldnt have written this.
This is already what happens when it writes the files with a (n) extension. My hook is explicitly to catch that and give control to the user. If the UI actually previewed the metadata and file state before the file was written, there'd be no issue because you could in fact alert the user to the preexisting files. However Picard is blind to the state of anything not in memory, and doesnt even update those states until they are commited during a save. If you don't like plugins that use the hook, don't use them. That has no bearing on the existence of the hook itself. |
All I was saying that I think we should be very careful reviewing plugins that make use of the hook :) And specifically changing metadata is something that (official) plugins likely should not do in this hook. |
|
I've reread the conversation. I think that my initial choice of the term metadata when I really meant file state has caused unneeded confusion. I apologize for that. The comments in the code could have been better. |
Summary
Problem
I may want to have multiple copies of a release i.e. a flac, a low compression and high compression copy for different uses. I want to be able to set my own disambiguation patterns instead of rely on the built-in (n) routine.
The post save hook is too late - the file has already moved, and nothing preserves that information.
https://picard-docs.musicbrainz.org/en/appendices/plugins_api.html#file-post-save-processor-file exists, but no pre-save equivalent does.
See ticket PICARD-3133.
Solution
With a pre-save hook, I can capture file collisions and handle them as part of the file naming script. So I created one.
Action
Additional actions required: