a few more necessary album.store()s

This commit is contained in:
Adrian Sampson 2013-08-21 11:23:09 -07:00
parent 6677cea036
commit deef7f9d20
3 changed files with 8 additions and 4 deletions

View file

@ -962,14 +962,15 @@ def update_items(lib, query, album, move, pretend):
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()

View file

@ -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)

View file

@ -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):