From 94df742a590fa15c6ed99af2aafbc800fd082fe3 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 23 Apr 2009 02:00:52 +0900 Subject: [PATCH] fix bug with zero imports, improve speed with zero imports --- anki/importing/__init__.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/anki/importing/__init__.py b/anki/importing/__init__.py index 0799eafca..eb61cfd96 100644 --- a/anki/importing/__init__.py +++ b/anki/importing/__init__.py @@ -55,14 +55,14 @@ class Importer(object): self.deck.startProgress(num) self.deck.updateProgress(_("Importing...")) c = self.foreignCards() - self.importCards(c) - self.deck.updateProgress() - self.deck.updateCardTags(self.cardIds) - self.deck.updateProgress() - self.deck.updatePriorities(self.cardIds) - if random: + if self.importCards(c): self.deck.updateProgress() - self.deck.randomizeNewCards(self.cardIds) + self.deck.updateCardTags(self.cardIds) + self.deck.updateProgress() + self.deck.updatePriorities(self.cardIds) + if random: + self.deck.updateProgress() + self.deck.randomizeNewCards(self.cardIds) self.deck.finishProgress() if c: self.deck.setModified() @@ -127,12 +127,13 @@ all but one card template.""")) # strip invalid cards cards = self.stripInvalid(cards) cards = self.stripOrTagDupes(cards) + self.cardIds = [] if cards: self.addCards(cards) + return cards def addCards(self, cards): "Add facts in bulk from foreign cards." - self.cardIds = [] # map tags field to attr try: idx = self.mapping.index(0)