From cdb9c07dc08db903b870eece2e3defe1558c6fa9 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 31 Jan 2018 15:33:58 +1000 Subject: [PATCH] make sure we don't import v1 scheduling into a v2 collection --- anki/importing/anki2.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/anki/importing/anki2.py b/anki/importing/anki2.py index 9510176ff..b06cccce8 100644 --- a/anki/importing/anki2.py +++ b/anki/importing/anki2.py @@ -31,12 +31,19 @@ class Anki2Importer(Importer): self.src.close(save=False) def _prepareFiles(self): - if self.file.endswith(".anki21") and self.col.schedVer() == 1: + importingV2 = self.file.endswith(".anki21") + if importingV2 and self.col.schedVer() == 1: raise Exception("V2 scheduler must be enabled to import this file.") self.dst = self.col self.src = Collection(self.file) + if not importingV2 and self.col.schedVer() != 1: + # if v2 scheduler enabled, can't import v1 decks that include scheduling + if self.src.db.scalar("select 1 from cards where queue != 0 limit 1"): + self.src.close(save=False) + raise Exception("V2 scheduler can not import V1 decks with scheduling included.") + def _import(self): self._decks = {} if self.deckPrefix: