From deef7f9d20decb73f19f0e56225913be53d9ad70 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Wed, 21 Aug 2013 11:23:09 -0700 Subject: [PATCH] a few more necessary album.store()s --- beets/ui/commands.py | 9 +++++---- beetsplug/fetchart.py | 2 ++ test/test_ui.py | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 3004fb229..c835b8bb8 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -959,17 +959,18 @@ def update_items(lib, query, album, move, pretend): if album_id is None: # Singletons. continue album = lib.get_album(album_id) - if not album: # Empty albums have already been removed. + if not album: # Empty albums have already been removed. log.debug('emptied album %i' % album_id) continue - al_items = list(album.items()) + first_item = album.items().get() # Update album structure to reflect an item in it. for key in library.ALBUM_KEYS_ITEM: - setattr(album, key, getattr(al_items[0], key)) + album[key] = first_item[key] + album.store() # Move album art (and any inconsistent items). - if move and lib.directory in ancestry(al_items[0].path): + if move and lib.directory in ancestry(first_item.path): log.debug('moving album %i' % album_id) album.move() diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index 15986c8d1..61361f169 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -216,6 +216,7 @@ def batch_fetch_art(lib, albums, force, maxwidth=None): if path: album.set_art(path, False) + album.store() message = 'found album art' else: message = 'no art found' @@ -274,6 +275,7 @@ class FetchArtPlugin(BeetsPlugin): src_removed = config['import']['delete'].get(bool) or \ config['import']['move'].get(bool) album.set_art(path, not src_removed) + album.store() if src_removed: task.prune(path) diff --git a/test/test_ui.py b/test/test_ui.py index bbbcfb7c0..4f1a6a6e6 100644 --- a/test/test_ui.py +++ b/test/test_ui.py @@ -299,6 +299,7 @@ class UpdateTest(_common.TestCase): artfile = os.path.join(_common.RSRC, 'testart.jpg') _common.touch(artfile) self.album.set_art(artfile) + self.album.store() os.remove(artfile) def _update(self, query=(), album=False, move=False, reset_mtime=True):