Skip to content

Commit

Permalink
Change config key from "single" to "item"
Browse files Browse the repository at this point in the history
For consistency with the rest of the terminology in the docs/config.
Also, correct the documentation (which previously only covered albums).
  • Loading branch information
sampsyo committed Aug 21, 2022
1 parent bcc8903 commit 3c945cb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion beets/config_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import:
search_ids: []
duplicate_keys:
album: albumartist album
single: artist title
item: artist title
duplicate_action: ask
bell: no
set_fields: {}
Expand Down
2 changes: 1 addition & 1 deletion beets/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ def find_duplicates(self, lib):
# Query for existing items using the same metadata. We use a
# temporary `Item` object to generate any computed fields.
tmp_item = library.Item(lib, **info)
keys = config['import']['duplicate_keys']['single'].as_str_seq()
keys = config['import']['duplicate_keys']['item'].as_str_seq()
dup_query = library.Album.all_fields_query({
key: tmp_item.get(key)
for key in keys
Expand Down
12 changes: 9 additions & 3 deletions docs/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,16 @@ Default: ``yes``.
duplicate_keys
~~~~~~~~~~~~~~

The fields used to find duplicates in import task.
If several albums have the same value for each key, they will be considered duplicates.
The fields used to find duplicates when importing.
There are two sub-values here: ``album`` and ``item``.
Each one is a list of field names; if an existing object (album or item) in
the library matches the new object on all of these fields, the importer will
consider it a duplicate.

Default: ``albumartist album``
Default::

album: albumartist album
item: artist title

.. _duplicate_action:

Expand Down
4 changes: 2 additions & 2 deletions test/test_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ def setUp(self):
self.importer = self.create_importer()
config['import']['autotag'] = True
config['import']['singletons'] = True
config['import']['duplicate_keys']['single'] = 'artist title'
config['import']['duplicate_keys']['item'] = 'artist title'

def tearDown(self):
self.teardown_beets()
Expand Down Expand Up @@ -1397,7 +1397,7 @@ def test_skip_duplicate(self):
self.assertEqual(item.mb_trackid, 'old trackid')

def test_keep_when_extra_key_is_different(self):
config['import']['duplicate_keys']['single'] = 'artist title flex'
config['import']['duplicate_keys']['item'] = 'artist title flex'
item = self.lib.items().get()
item.flex = 'different'
item.store()
Expand Down

0 comments on commit 3c945cb

Please sign in to comment.