more friendly message for v2 import into v1

This commit is contained in:
Damien Elmes 2021-07-08 10:32:27 +10:00
parent 4dece5a972
commit c322f68ab8
2 changed files with 11 additions and 1 deletions

View file

@ -21,6 +21,10 @@ MID = 2
MOD = 3 MOD = 3
class V2ImportIntoV1(Exception):
pass
class Anki2Importer(Importer): class Anki2Importer(Importer):
needMapper = False needMapper = False
@ -58,7 +62,7 @@ class Anki2Importer(Importer):
if self.src.db.scalar("select 1 from cards where queue != 0 limit 1"): if self.src.db.scalar("select 1 from cards where queue != 0 limit 1"):
self.source_needs_upgrade = True self.source_needs_upgrade = True
elif self._importing_v2 and self.col.sched_ver() == 1: 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: def _import(self) -> None:
self._decks = {} self._decks = {}

View file

@ -14,6 +14,7 @@ import anki.importing as importing
import aqt.deckchooser import aqt.deckchooser
import aqt.forms import aqt.forms
import aqt.modelchooser import aqt.modelchooser
from anki.importing.anki2 import V2ImportIntoV1
from anki.importing.apkg import AnkiPackageImporter from anki.importing.apkg import AnkiPackageImporter
from aqt import AnkiQt, gui_hooks from aqt import AnkiQt, gui_hooks
from aqt.qt import * from aqt.qt import *
@ -394,6 +395,11 @@ def importFile(mw: AnkiQt, file: str) -> None:
future.result() future.result()
except zipfile.BadZipfile: except zipfile.BadZipfile:
showWarning(invalidZipMsg()) 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: except Exception as e:
err = repr(str(e)) err = repr(str(e))
if "invalidFile" in err: if "invalidFile" in err: