diff --git a/pylib/anki/importing/anki2.py b/pylib/anki/importing/anki2.py index eea31ca62..b295df974 100644 --- a/pylib/anki/importing/anki2.py +++ b/pylib/anki/importing/anki2.py @@ -21,6 +21,10 @@ MID = 2 MOD = 3 +class V2ImportIntoV1(Exception): + pass + + class Anki2Importer(Importer): needMapper = False @@ -58,7 +62,7 @@ class Anki2Importer(Importer): if self.src.db.scalar("select 1 from cards where queue != 0 limit 1"): self.source_needs_upgrade = True elif self._importing_v2 and self.col.sched_ver() == 1: - raise Exception("must upgrade to new scheduler to import this file") + raise V2ImportIntoV1() def _import(self) -> None: self._decks = {} diff --git a/qt/aqt/importing.py b/qt/aqt/importing.py index 4d3e62a8a..ee0a4ac46 100644 --- a/qt/aqt/importing.py +++ b/qt/aqt/importing.py @@ -14,6 +14,7 @@ import anki.importing as importing import aqt.deckchooser import aqt.forms import aqt.modelchooser +from anki.importing.anki2 import V2ImportIntoV1 from anki.importing.apkg import AnkiPackageImporter from aqt import AnkiQt, gui_hooks from aqt.qt import * @@ -394,6 +395,11 @@ def importFile(mw: AnkiQt, file: str) -> None: future.result() except zipfile.BadZipfile: showWarning(invalidZipMsg()) + except V2ImportIntoV1: + showWarning( + """\ +To import this deck, please click the Update button at the top of the deck list, then try again.""" + ) except Exception as e: err = repr(str(e)) if "invalidFile" in err: