diff --git a/beets/library.py b/beets/library.py index edd79d243..36e5a5d22 100644 --- a/beets/library.py +++ b/beets/library.py @@ -1016,7 +1016,8 @@ class Album(LibModel): # Move items. items = list(self.items()) for item in items: - item.move(copy, link, basedir=basedir, with_album=False) + item.move(copy, link, basedir=basedir, with_album=False, + fields_to_store=fields_to_store) # Move art. self.move_art(copy, link) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 823e99cfa..d44bbadc6 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -1086,6 +1086,11 @@ def update_items(lib, query, album, move, pretend, fields): reflect the item's embedded tags. """ with lib.transaction(): + if move and fields is not None and 'path' not in fields: + # Special case: if an item needs to be moved, the path field has to + # updated; otherwise the new path will not be reflected in the + # database + fields.append('path') items, _ = _do_query(lib, query, album) # Walk through the items and pick up their changes. diff --git a/test/test_ui.py b/test/test_ui.py index 571f39cf8..380b29173 100644 --- a/test/test_ui.py +++ b/test/test_ui.py @@ -550,6 +550,26 @@ class UpdateTest(_common.TestCase): item = self.lib.items().get() self.assertTrue(b'differentTitle' not in item.path) + def test_selective_modified_metadata_moved(self): + mf = MediaFile(self.i.path) + mf.title = u'differentTitle' + mf.genre = u'differentGenre' + mf.save() + self._update(move=True, fields=['title']) + item = self.lib.items().get() + self.assertTrue(b'differentTitle' in item.path) + self.assertNotEqual(item.genre, u'differentGenre') + + def test_selective_modified_metadata_not_moved(self): + mf = MediaFile(self.i.path) + mf.title = u'differentTitle' + mf.genre = u'differentGenre' + mf.save() + self._update(move=False, fields=['title']) + item = self.lib.items().get() + self.assertTrue(b'differentTitle' not in item.path) + self.assertNotEqual(item.genre, u'differentGenre') + def test_modified_album_metadata_moved(self): mf = MediaFile(self.i.path) mf.album = u'differentAlbum'