mirror of
https://github.com/beetbox/beets.git
synced 2026-02-08 08:25:23 +01:00
importsource: Only register listener if configured
and remove the now redundant config sanity check in suggest_removal().
This commit is contained in:
parent
6c2c46091b
commit
25e0d3064e
1 changed files with 14 additions and 15 deletions
|
|
@ -26,17 +26,19 @@ class ImportSourcePlugin(BeetsPlugin):
|
|||
}
|
||||
)
|
||||
self.import_stages = [self.import_stage]
|
||||
self.register_listener("item_removed", self.suggest_removal)
|
||||
# In order to stop future removal suggestions for an album we keep
|
||||
# track of `mb_albumid`s in this set.
|
||||
self.stop_suggestions_for_albums = set()
|
||||
# During reimports (import --library) both the import_task_choice and
|
||||
# the item_removed event are triggered. The item_removed event is
|
||||
# triggered first. For the import_task_choice event we prevent removal
|
||||
# suggestions using the existing stop_suggestions_for_album mechanism.
|
||||
self.register_listener(
|
||||
"import_task_choice", self.prevent_suggest_removal
|
||||
)
|
||||
# Only register removal suggestion listeners if the feature is enabled
|
||||
if self.config["suggest_removal"]:
|
||||
# In order to stop future removal suggestions for an album we keep
|
||||
# track of `mb_albumid`s in this set.
|
||||
self.stop_suggestions_for_albums = set()
|
||||
self.register_listener("item_removed", self.suggest_removal)
|
||||
# During reimports (import --library) both the import_task_choice and
|
||||
# the item_removed event are triggered. The item_removed event is
|
||||
# triggered first. For the import_task_choice event we prevent removal
|
||||
# suggestions using the existing stop_suggestions_for_album mechanism.
|
||||
self.register_listener(
|
||||
"import_task_choice", self.prevent_suggest_removal
|
||||
)
|
||||
|
||||
def prevent_suggest_removal(self, session, task):
|
||||
if task.skip:
|
||||
|
|
@ -60,10 +62,7 @@ class ImportSourcePlugin(BeetsPlugin):
|
|||
|
||||
def suggest_removal(self, item):
|
||||
"""Prompts the user to delete the original path the item was imported from."""
|
||||
if (
|
||||
not self.config["suggest_removal"]
|
||||
or item.mb_albumid in self.stop_suggestions_for_albums
|
||||
):
|
||||
if item.mb_albumid in self.stop_suggestions_for_albums:
|
||||
return
|
||||
|
||||
if "source_path" not in item:
|
||||
|
|
|
|||
Loading…
Reference in a new issue