Skip to content

Commit

Permalink
Clarify Album.store() docstring and comments,
Browse files Browse the repository at this point in the history
explaining the inherit flag, fixed/flex attrs and the strict exclusion
of the id field.
  • Loading branch information
JOJ0 committed Aug 6, 2023
1 parent 018910d commit a6937f0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -1372,20 +1372,22 @@ def set_art(self, path, copy=True):
def store(self, fields=None, inherit=True):
"""Update the database with the album information.
The album's tracks are also updated.
`fields` represents the fields to be stored. If not specified,
all fields will be.
The album's tracks are also updated when the `inherit` flag is enabled.
This applies to fixed attributes as well as flexible ones. The `id`
attribute of the album will never be inherited.
"""
# Get modified track fields.
track_updates = {}
track_deletes = set()
for key in self._dirty:
if key in self.item_keys and inherit:
if key in self.item_keys and inherit: # Fixed attr
track_updates[key] = self[key]
elif key not in self and inherit:
elif key not in self and inherit: # Fixed or flex attr
track_deletes.add(key)
elif key != 'id' and inherit: # Could be a flex attr or id
elif key != 'id' and inherit: # Could be a flex attr or id (fixed)
track_updates[key] = self[key]

with self._db.transaction():
Expand Down

0 comments on commit a6937f0

Please sign in to comment.