Skip to content

Commit

Permalink
Refactor Album.store for code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
JOJ0 committed Aug 23, 2023
1 parent 62f2064 commit cc3c700
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -1383,12 +1383,13 @@ def store(self, fields=None, inherit=True):
track_updates = {}
track_deletes = set()
for key in self._dirty:
if key in self.item_keys and inherit: # Fixed attr
track_updates[key] = self[key]
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 (fixed)
track_updates[key] = self[key]
if inherit:
if key in self.item_keys: # is a fixed attribute
track_updates[key] = self[key]
elif key not in self: # is a fixed or a flexible attribute
track_deletes.add(key)
elif key != 'id': # is a flexible attribute
track_updates[key] = self[key]

with self._db.transaction():
super().store(fields)
Expand Down

0 comments on commit cc3c700

Please sign in to comment.