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

@ -959,17 +959,18 @@ def update_items(lib, query, album, move, pretend):
if album_id is None: # Singletons. if album_id is None: # Singletons.
continue continue
album = lib.get_album(album_id) 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) log.debug('emptied album %i' % album_id)
continue continue
al_items = list(album.items()) first_item = album.items().get()
# Update album structure to reflect an item in it. # Update album structure to reflect an item in it.
for key in library.ALBUM_KEYS_ITEM: 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). # 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) log.debug('moving album %i' % album_id)
album.move() album.move()

View file

@ -216,6 +216,7 @@ def batch_fetch_art(lib, albums, force, maxwidth=None):
if path: if path:
album.set_art(path, False) album.set_art(path, False)
album.store()
message = 'found album art' message = 'found album art'
else: else:
message = 'no art found' message = 'no art found'
@ -274,6 +275,7 @@ class FetchArtPlugin(BeetsPlugin):
src_removed = config['import']['delete'].get(bool) or \ src_removed = config['import']['delete'].get(bool) or \
config['import']['move'].get(bool) config['import']['move'].get(bool)
album.set_art(path, not src_removed) album.set_art(path, not src_removed)
album.store()
if src_removed: if src_removed:
task.prune(path) task.prune(path)

View file

@ -299,6 +299,7 @@ class UpdateTest(_common.TestCase):
artfile = os.path.join(_common.RSRC, 'testart.jpg') artfile = os.path.join(_common.RSRC, 'testart.jpg')
_common.touch(artfile) _common.touch(artfile)
self.album.set_art(artfile) self.album.set_art(artfile)
self.album.store()
os.remove(artfile) os.remove(artfile)
def _update(self, query=(), album=False, move=False, reset_mtime=True): def _update(self, query=(), album=False, move=False, reset_mtime=True):