-
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
mtime
reset when assigning unchanged values to Item
fields
#2664
Comments
Hmm! This is a very good point. Thanks for the thorough investigation—it made the problem easy to understand. I think you’re right that we should change the behavior of Here’s one possible fix: in That seems like it could be a pretty simple (but effective) change, if I’m envisioning the necessary code correctly. |
Factoring this into a separate I'll open a PR once I've come up with a test for the |
That sounds great! Woohoo! The tests in |
Turns out that there's a test already... but it's broken due to the way test fixtures are set up :/ |
It looks like the linked PR fixed this issue. Can we close this @wisp3rwind? |
Yes, I just read through the PR and its commits again and it looks like all of this was fixed. Thanks for the reminder! |
Problem
In
library.py
the
mtime
will be reset (and consequentlyItem._dirty
be set) irrespective of whether any field actuallychanged. Most of the time, this is probably not a problem since the item would be dirtied anyway, and even if not, no real database corruption will occur. There is a particular situation where many unnecessary
mtime
updates and metadata writes to the mediafiles can be triggered, though:Into the following
beet edit
session, the query selected a full album, but I only changed one song title:but still all of the items are committed to the database and have their metadata written out to the files. This happens because the edit plugin assigns all fields whether they were changed or not, and then checks
Item._dirty
and if it is non-empty callsItem.try_sync
. Given that themtime
is always changed, the_dirty
check is useless.While the edit plugin should probably not re-assign unchanged fields in the first place, it seems to me that the behaviour of
Item.__setitem__
is not ideal either. I'm not really sure about the implications for beets overall, but a first (untested) "fix" could be the following (Item._dirty
is just aset()
):Maybe copying this
set()
all the time has performance implications and there's a better way?Any thoughts on how
__setitem__
should behave? Or would it be safer to only change the edit plugin?The text was updated successfully, but these errors were encountered: