Skip to content

Commit

Permalink
Merge pull request #2056 from dixoncx/fix_issue_185
Browse files Browse the repository at this point in the history
Fix issue #185
  • Loading branch information
sampsyo authored Jun 19, 2016
2 parents 2669b35 + 4d75d4c commit b5e1ac7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions beets/config_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import:
group_albums: no
pretend: false
search_ids: []
duplicate_action: ask

clutter: ["Thumbs.DB", ".DS_Store"]
ignore: [".*", "*~", "System Volume Information", "lost+found"]
Expand Down
24 changes: 23 additions & 1 deletion beets/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,29 @@ def resolve_duplicates(session, task):
log.debug(u'found duplicates: {}'.format(
[o.id for o in found_duplicates]
))
session.resolve_duplicate(task, found_duplicates)

# Get the default action to follow from config.
duplicate_action = config['import']['duplicate_action'].as_choice({
u'skip': u's',
u'keep': u'k',
u'remove': u'r',
u'ask': u'a',
})
log.debug(u'default action for duplicates: {0}', duplicate_action)

if duplicate_action == u's':
# Skip new.
task.set_choice(action.SKIP)
elif duplicate_action == u'k':
# Keep both. Do nothing; leave the choice intact.
pass
elif duplicate_action == u'r':
# Remove old.
task.should_remove_duplicates = True
else:
# No default action set; ask the session.
session.resolve_duplicate(task, found_duplicates)

session.log_choice(task, True)


Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ New features:

* A new ``--force`` option for :ref:`remove-cmd` allows removal of items
without prompting beforehand. :bug:`2042`
* A new importer configuration :ref:`duplicate_action` controls how
duplicate albums or tracks treated in import task. :bug:`185`

Some fixes for Windows:

Expand Down
11 changes: 11 additions & 0 deletions docs/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,17 @@ with the ``-a`` flag to the :ref:`import-cmd` command.)

Default: ``yes``.

.. _duplicate_action:

duplicate_action
~~~~~~~~~~~~~~~~

Either ``skip``, ``keep``, ``remove``, or ``ask``. Controls how duplicates
are treated in import task. "skip" means that new item(album or track) will be
skiped; "keep" means keep both old and new items; "remove" means remove old
item; "ask" means the user should be prompted for the action each time.
The default is ``ask``.


.. _musicbrainz-config:

Expand Down

0 comments on commit b5e1ac7

Please sign in to comment.