mirror of
https://github.com/beetbox/beets.git
synced 2026-01-14 04:01:43 +01:00
Pass found duplicates between task and session
This commit is contained in:
parent
a15cf2b001
commit
3ec7426a35
2 changed files with 6 additions and 8 deletions
|
|
@ -250,7 +250,7 @@ class ImportSession(object):
|
|||
def choose_match(self, task):
|
||||
raise NotImplementedError
|
||||
|
||||
def resolve_duplicate(self, task):
|
||||
def resolve_duplicate(self, task, found_duplicates):
|
||||
raise NotImplementedError
|
||||
|
||||
def choose_item(self, task):
|
||||
|
|
@ -355,8 +355,6 @@ class ImportTask(object):
|
|||
self.should_remove_duplicates = False
|
||||
self.is_album = True
|
||||
|
||||
self.found_duplicates = None
|
||||
|
||||
def set_null_candidates(self):
|
||||
"""Set the candidates to indicate no album match was found.
|
||||
"""
|
||||
|
|
@ -536,7 +534,6 @@ class ImportTask(object):
|
|||
album_paths = set(i.path for i in album.items())
|
||||
if album_paths != task_paths:
|
||||
duplicates.append(album)
|
||||
self.found_duplicates = duplicates
|
||||
return duplicates
|
||||
|
||||
def infer_album_fields(self):
|
||||
|
|
@ -1059,8 +1056,9 @@ def resolve_duplicates(session, task):
|
|||
"""
|
||||
if task.choice_flag in (action.ASIS, action.APPLY):
|
||||
ident = task.chosen_ident()
|
||||
if ident in session.seen_idents or task.find_duplicates(session.lib):
|
||||
session.resolve_duplicate(task)
|
||||
found_duplicates = task.find_duplicates(session.lib)
|
||||
if ident in session.seen_idents or found_duplicates:
|
||||
session.resolve_duplicate(task, found_duplicates)
|
||||
session.log_choice(task, True)
|
||||
session.seen_idents.add(ident)
|
||||
|
||||
|
|
|
|||
|
|
@ -741,7 +741,7 @@ class TerminalImportSession(importer.ImportSession):
|
|||
assert isinstance(choice, autotag.TrackMatch)
|
||||
return choice
|
||||
|
||||
def resolve_duplicate(self, task):
|
||||
def resolve_duplicate(self, task, found_duplicates):
|
||||
"""Decide what to do when a new album or item seems similar to one
|
||||
that's already in the library.
|
||||
"""
|
||||
|
|
@ -754,7 +754,7 @@ class TerminalImportSession(importer.ImportSession):
|
|||
sel = 's'
|
||||
else:
|
||||
# print some detail about the existing and new items so it can be an informed decision
|
||||
for duplicate in task.found_duplicates:
|
||||
for duplicate in found_duplicates:
|
||||
old_items = [(item.path, item.format, item.bitrate, item.length) for item in duplicate.items()]
|
||||
print("OLD: " + util.summarize_items(old_items))
|
||||
new_items = [(item.path, item.format, item.bitrate, item.length) for item in task.items]
|
||||
|
|
|
|||
Loading…
Reference in a new issue