importsource: Catch importer crash when skipping

Catches a crash when "skip" is selected in the importer and
task.imported_items() runs into a condition branch that supposedly
should never be reached:

  File "beets/beets/importer/tasks.py", line 254, in imported_items
    assert False
This commit is contained in:
J0J0 Todos 2025-12-05 16:46:35 +01:00
parent 2bd77b9895
commit 4f95a2f25a

View file

@ -39,9 +39,13 @@ class ImportSourcePlugin(BeetsPlugin):
) )
def prevent_suggest_removal(self, session, task): def prevent_suggest_removal(self, session, task):
try:
for item in task.imported_items(): for item in task.imported_items():
if "mb_albumid" in item: if "mb_albumid" in item:
self.stop_suggestions_for_albums.add(item.mb_albumid) self.stop_suggestions_for_albums.add(item.mb_albumid)
except AssertionError:
# No imported items - nothing to do
pass
def import_stage(self, _, task): def import_stage(self, _, task):
"""Event handler for albums import finished.""" """Event handler for albums import finished."""