diff --git a/beets/library.py b/beets/library.py index 9f7f56883..baf7a312d 100644 --- a/beets/library.py +++ b/beets/library.py @@ -1369,7 +1369,7 @@ class Album(LibModel): plugins.send('art_set', album=self) - def store(self, fields=None): + def store(self, fields=None, inherit=True): """Update the database with the album information. The album's tracks are also updated. @@ -1381,11 +1381,11 @@ class Album(LibModel): track_updates = {} track_deletes = set() for key in self._dirty: - if key in self.item_keys: + if key in self.item_keys and inherit: track_updates[key] = self[key] - elif key not in self: + elif key not in self and inherit: track_deletes.add(key) - else: # Must be a flex attr + elif inherit: # Must be a flex attr track_updates[key] = self[key] with self._db.transaction(): @@ -1402,7 +1402,7 @@ class Album(LibModel): del item[key] item.store() - def try_sync(self, write, move): + def try_sync(self, write, move, inherit=True): """Synchronize the album and its items with the database. Optionally, also write any new tags into the files and update their paths. @@ -1411,7 +1411,7 @@ class Album(LibModel): `move` controls whether files (both audio and album art) are moved. """ - self.store() + self.store(inherit=inherit) for item in self.items(): item.try_sync(write, move) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 750457234..8e6fda8e8 100755 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -1489,7 +1489,7 @@ default_commands.append(version_cmd) # modify: Declaratively change metadata. -def modify_items(lib, mods, dels, query, write, move, album, confirm): +def modify_items(lib, mods, dels, query, write, move, album, confirm, inherit): """Modifies matching items according to user-specified assignments and deletions. @@ -1542,7 +1542,7 @@ def modify_items(lib, mods, dels, query, write, move, album, confirm): # Apply changes to database and files with lib.transaction(): for obj in changed: - obj.try_sync(write, move) + obj.try_sync(write, move, inherit) def print_and_modify(obj, mods, dels): @@ -1585,7 +1585,8 @@ def modify_func(lib, opts, args): if not mods and not dels: raise ui.UserError('no modifications specified') modify_items(lib, mods, dels, query, ui.should_write(opts.write), - ui.should_move(opts.move), opts.album, not opts.yes) + ui.should_move(opts.move), opts.album, not opts.yes, + opts.inherit) modify_cmd = ui.Subcommand( @@ -1613,6 +1614,10 @@ modify_cmd.parser.add_option( '-y', '--yes', action='store_true', help='skip confirmation' ) +modify_cmd.parser.add_option( + '-I', '--noinherit', action='store_false', dest='inherit', default=True, + help="Don't inherit album-changes to tracks" +) modify_cmd.func = modify_func default_commands.append(modify_cmd)