From e69522f120d0845e9bdd92fe6c4880aeda7aa6b4 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 6 Oct 2008 18:41:50 +0900 Subject: [PATCH] ensure order of received cards --- anki/deck.py | 3 ++- anki/sync.py | 10 +++++----- tests/test_sync.py | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/anki/deck.py b/anki/deck.py index 4476036ab..371339839 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -1176,7 +1176,8 @@ where id = :id""" % table, pending) def name(self): n = os.path.splitext(os.path.basename(self.path))[0] - n = re.sub("[^-A-Za-z0-9_+<>[]() ]", "", n) + assert '/' not in n + assert '\\' not in n return n # Media diff --git a/anki/sync.py b/anki/sync.py index b1c5ae3f6..a8a551d4f 100644 --- a/anki/sync.py +++ b/anki/sync.py @@ -755,7 +755,7 @@ where media.id in %s""" % sids, now=time.time()) def getOneWayCards(self, ids): "The minimum information necessary to generate one way cards." return self.deck.s.all( - "select id, factId, cardModelId, ordinal from cards " + "select id, factId, cardModelId, ordinal, created from cards " "where id in %s" % ids2str(ids)) def updateOneWayCards(self, cards): @@ -763,7 +763,7 @@ where media.id in %s""" % sids, now=time.time()) return t = time.time() dlist = [{'id': c[0], 'factId': c[1], 'cardModelId': c[2], - 'ordinal': c[3], 't': t} for c in cards] + 'ordinal': c[3], 'created': c[4], 't': t} for c in cards] # add any missing cards self.deck.s.statements(""" insert or ignore into cards @@ -775,8 +775,8 @@ matureEase1, matureEase2, matureEase3, matureEase4, yesCount, noCount, question, answer, lastFactor, spaceUntil, isDue, type, combinedDue, relativeDelay) values -(:id, :factId, :cardModelId, :t, :t, "", :ordinal, -1, 0.001, 0, :t, 0, 2.5, +(:id, :factId, :cardModelId, :created, :t, "", :ordinal, +1, 0.001, 0, :created, 0, 2.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -952,7 +952,7 @@ class HttpSyncServer(SyncServer): return self.stuff(SyncServer.genOneWayPayload(self, self.unstuff(payload))) - def getDecks(self, libanki, client): + def getDecks(self, libanki, client, sources): return self.stuff({ "status": "OK", "decks": self.decks, diff --git a/tests/test_sync.py b/tests/test_sync.py index 61567990e..bb3bedbbb 100644 --- a/tests/test_sync.py +++ b/tests/test_sync.py @@ -248,6 +248,7 @@ def test_localsync_media(): def test_oneway_simple(): assert deck1.s.scalar("select count(1) from cards") == 2 assert deck2.s.scalar("select count(1) from cards") == 2 + server.deckName = "dummy" client.syncOneWay(0) assert deck1.s.scalar("select count(1) from cards") == 4 assert deck2.s.scalar("select count(1) from cards") == 2