diff --git a/anki/importing/anki2.py b/anki/importing/anki2.py index 070c13d43..0c7739be5 100644 --- a/anki/importing/anki2.py +++ b/anki/importing/anki2.py @@ -19,7 +19,6 @@ class Anki2Importer(Importer): needMapper = False deckPrefix = None allowUpdate = True - dupeOnSchemaChange = False def run(self, media=None): self._prepareFiles() @@ -65,9 +64,8 @@ class Anki2Importer(Importer): # we may need to rewrite the guid if the model schemas don't match, # so we need to keep track of the changes for the card import stage self._changedGuids = {} - # apart from upgrading from anki1 decks, we ignore updates to changed - # schemas. we need to note the ignored guids, so we avoid importing - # invalid cards + # we ignore updates to changed schemas. we need to note the ignored + # guids, so we avoid importing invalid cards self._ignoredGuids = {} # iterate over source collection add = [] @@ -149,20 +147,9 @@ class Anki2Importer(Importer): note[MID] = dstMid if origGuid not in self._notes: return True - # as the schemas differ and we already have a note with a different - # note type, this note needs a new guid - if not self.dupeOnSchemaChange: - self._ignoredGuids[origGuid] = True - return False - while True: - note[GUID] = incGuid(note[GUID]) - self._changedGuids[origGuid] = note[GUID] - # if we don't have an existing guid, we can add - if note[GUID] not in self._notes: - return True - # if the existing guid shares the same mid, we can reuse - if dstMid == self._notes[note[GUID]][MID]: - return False + # schema changed; don't import + self._ignoredGuids[origGuid] = True + return False # Models ###################################################################### diff --git a/tests/test_importing.py b/tests/test_importing.py index 15eb7d0fb..65e418a6e 100644 --- a/tests/test_importing.py +++ b/tests/test_importing.py @@ -75,38 +75,6 @@ def test_apkg(): imp.run() assert len(os.listdir(tmp.media.dir())) == 2 -def test_anki2_diffmodels(): - # create a new empty deck - dst = getEmptyCol() - # import the 1 card version of the model - tmp = getUpgradeDeckPath("diffmodels2-1.apkg") - imp = AnkiPackageImporter(dst, tmp) - imp.dupeOnSchemaChange = True - imp.run() - before = dst.noteCount() - # repeating the process should do nothing - imp = AnkiPackageImporter(dst, tmp) - imp.dupeOnSchemaChange = True - imp.run() - assert before == dst.noteCount() - # then the 2 card version - tmp = getUpgradeDeckPath("diffmodels2-2.apkg") - imp = AnkiPackageImporter(dst, tmp) - imp.dupeOnSchemaChange = True - imp.run() - after = dst.noteCount() - # as the model schemas differ, should have been imported as new model - assert after == before + 1 - # and the new model should have both cards - assert dst.cardCount() == 3 - # repeating the process should do nothing - imp = AnkiPackageImporter(dst, tmp) - imp.dupeOnSchemaChange = True - imp.run() - after = dst.noteCount() - assert after == before + 1 - assert dst.cardCount() == 3 - def test_anki2_diffmodel_templates(): # different from the above as this one tests only the template text being # changed, not the number of cards/fields