-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
check config opt import/write before try_write from art.py (fixes #1427) #1428
Conversation
item.try_write(path=itempath, tags={'images': [image]}) | ||
|
||
write = config['import']['write'].get(bool) | ||
if write: |
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.
This can just be if config['import']['write']:
(that is, no .get(bool)
necessary when used in a condition).
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.
Heh, sorry. Copied the code from elsewhere in the repo. My python atrophies quickly.
There are two possible policies here:
This change will chooses option 2. That seems fine to me—but if we're going to do that, then we might as well also skip the similarity comparison, the width check, etc., which is all wasted work. So perhaps the plugin should just never call |
Hmm, good question. Since My use model is to run If some of the products would end up being recreated, then that would definitely add up to a lot of wasted work for large imports using Another question about this PR: With the current PR, I was focused on the case where |
The work performed on download (i.e., by the
Aha, good point! Yes. It does seem that the explicit command should always actually write the files. |
As an additional note: Some tests for the |
My current fix for (diff: reynhout@f6e0499 ) Is that a reasonable path? It's hard to avoid treating I agree on tests, I'll take a look in there too. |
Thanks for continuing to look into this! The cleanest way to do this would be to check the flag in the plugin's event handler, not in art.py. That will skip the entire call to the embed functions—and you're right, this will also skip the similarity check and such, but I actually think that's for the best. A "dry run" kind of functionality would be interesting but could be implemented separately. |
Ah yes. That makes it much simpler. Thank you for clarifying. I'll close this PR and add the updated patch to the issue report. Then take a look at tests. |
No description provided.