From 36d332ab6a96306d93d086ddbdfd97d5a5631db1 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Thu, 13 Nov 2014 23:25:16 -0800 Subject: [PATCH] Fix #856: album dirty tracking --- beets/dbcore/db.py | 8 +++++++- beets/library.py | 1 + docs/changelog.rst | 3 +++ test/test_library.py | 10 ++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/beets/dbcore/db.py b/beets/dbcore/db.py index 0548c6c2f..0c786daa5 100644 --- a/beets/dbcore/db.py +++ b/beets/dbcore/db.py @@ -129,6 +129,12 @@ class Model(object): are subclasses of `Sort`. """ + _always_dirty = False + """By default, fields only become "dirty" when their value actually + changes. Enabling this flag marks fields as dirty even when the new + value is the same as the old value (e.g., `o.f = o.f`). + """ + @classmethod def _getters(cls): """Return a mapping from field names to getter functions. @@ -235,7 +241,7 @@ class Model(object): # Assign value and possibly mark as dirty. old_value = source.get(key) source[key] = value - if old_value != value: + if self._always_dirty or old_value != value: self._dirty.add(key) def __delitem__(self, key): diff --git a/beets/library.py b/beets/library.py index f4e8f6b61..3549b1778 100644 --- a/beets/library.py +++ b/beets/library.py @@ -702,6 +702,7 @@ class Album(LibModel): """ _table = 'albums' _flex_table = 'album_attributes' + _always_dirty = True _fields = { 'id': types.PRIMARY_ID, 'artpath': PathType(), diff --git a/docs/changelog.rst b/docs/changelog.rst index d66a37787..8d2cc2654 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -88,6 +88,9 @@ Fixes: * :doc:`/plugins/chroma`: Limit the number of releases and recordings fetched as the result of an Acoustid match to avoid extremely long processing times for very popular music. :bug:`1068` +* Fix an issue where modifying an album's field without actually changing it + would not update the corresponding tracks to bring differing tracks back in + line with the album. :bug:`856` 1.3.8 (September 17, 2014) diff --git a/test/test_library.py b/test/test_library.py index 458863190..38419e38e 100644 --- a/test/test_library.py +++ b/test/test_library.py @@ -836,6 +836,16 @@ class AlbumInfoTest(_common.TestCase): self.i.remove() self.assertEqual(len(self.lib.albums()), 0) + def test_noop_albuminfo_changes_affect_items(self): + i = self.lib.items()[0] + i.album = 'foobar' + i.store() + ai = self.lib.get_album(self.i) + ai.album = ai.album + ai.store() + i = self.lib.items()[0] + self.assertEqual(i.album, ai.album) + class ArtDestinationTest(_common.TestCase): def setUp(self):