From 3ec7426a35591b08c5a173b99a5ef603febbf348 Mon Sep 17 00:00:00 2001 From: Howard Jones Date: Mon, 18 Aug 2014 10:35:01 +0100 Subject: [PATCH] Pass found duplicates between task and session --- beets/importer.py | 10 ++++------ beets/ui/commands.py | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/beets/importer.py b/beets/importer.py index b0f56a497..76c90dbea 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -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) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index e0af65e7e..3eec70fd7 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -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]