diff --git a/anki/deck.py b/anki/deck.py index 71d59e947..e285c05c4 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -1868,12 +1868,13 @@ insert into undoLog values (null, 'insert into %(t)s (rowid""" % {'t': table} (start, end) = (u[1], u[2]) if end is None: end = self._latestUndoRow() - self.startProgress(_("Undo/Redo"), 0, 22) sql = self.s.column0(""" select sql from undoLog where seq > :s and seq <= :e order by seq desc""", s=start, e=end) mod = len(sql) / 20 - self.updateProgress(_("Applying changes...")) + if mod: + self.startProgress(_("Undo/Redo"), 0, 21) + self.updateProgress(_("Applying changes...")) newstart = self._latestUndoRow() for c, s in enumerate(sql): if mod and not c % mod: @@ -1882,7 +1883,8 @@ seq > :s and seq <= :e order by seq desc""", s=start, e=end) self.engine.execute(s) newend = self._latestUndoRow() dst.append([u[0], newstart, newend]) - self.finishProgress() + if mod: + self.finishProgress() def undo(self): self._undoredo(self.undoStack, self.redoStack) diff --git a/anki/exporting.py b/anki/exporting.py index 385d00592..2a6f91cb0 100644 --- a/anki/exporting.py +++ b/anki/exporting.py @@ -59,6 +59,11 @@ class AnkiExporter(Exporter): self.includeSchedulingInfo = False def exportInto(self, path): + n = 4 + if not self.includeSchedulingInfo: + n += 1 + self.deck.startProgress(_("Export"), 0, n) + self.deck.updateProgress(_("Determining items...")) self.newDeck = DeckStorage.Deck(path) client = SyncClient(self.deck) server = SyncServer(self.newDeck) @@ -69,10 +74,12 @@ class AnkiExporter(Exporter): # set up a custom change list and sync lsum = self.localSummary() rsum = server.summary(0) + self.deck.updateProgress(_("Copying...")) payload = client.genPayload((lsum, rsum)) + self.deck.updateProgress(_("Applying...")) res = server.applyPayload(payload) - client.applyPayloadReply(res) if not self.includeSchedulingInfo: + self.deck.updateProgress(_("Updating schedule...")) self.newDeck.s.statement(""" delete from reviewHistory""") self.newDeck.s.statement(""" @@ -114,10 +121,12 @@ delete from stats""") bulkClient.server = bulkServer bulkClient.sync() # need to save manually + self.deck.updateProgress(_("Finalizing...")) self.newDeck.rebuildCounts() self.exportedCards = self.newDeck.cardCount self.newDeck.s.commit() self.newDeck.close() + self.deck.finishProgress() def localSummary(self): cardIds = self.cardIds()