mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
more fixes for skewed clocks
if a client with a clock greater than server time synced a deck, the modified time ended up higher than lastSync when the deck was modified on the server. instead we force the modified time to be <= the server time, which is known correct.
This commit is contained in:
parent
d717be8849
commit
1f34abc003
1 changed files with 9 additions and 2 deletions
11
anki/sync.py
11
anki/sync.py
|
@ -613,7 +613,11 @@ values
|
|||
##########################################################################
|
||||
|
||||
def bundleDeck(self):
|
||||
self.deck.lastSync = time.time()
|
||||
# ensure modified is not greater than server time
|
||||
if getattr(self, "server", None):
|
||||
self.deck.modified = min(self.deck.modified,self.server.timestamp)
|
||||
# and ensure lastSync is greater than modified
|
||||
self.deck.lastSync = max(time.time(), self.deck.modified+1)
|
||||
d = self.dictFromObj(self.deck)
|
||||
del d['Session']
|
||||
del d['engine']
|
||||
|
@ -941,6 +945,9 @@ and cards.id in %s""" % ids2str([c[0] for c in cards])))
|
|||
|
||||
def prepareFullSync(self):
|
||||
t = time.time()
|
||||
# ensure modified is not greater than server time
|
||||
self.deck.modified = min(self.deck.modified, self.server.timestamp)
|
||||
self.deck.s.commit()
|
||||
self.deck.close()
|
||||
fields = {
|
||||
"p": self.server.password,
|
||||
|
@ -1004,7 +1011,7 @@ and cards.id in %s""" % ids2str([c[0] for c in cards])))
|
|||
sendProgressHook = fullSyncProgressHook
|
||||
res = urllib2.urlopen(req).read()
|
||||
assert res.startswith("OK")
|
||||
# update local modification time
|
||||
# update lastSync
|
||||
c = sqlite.connect(path)
|
||||
c.execute("update decks set lastSync = ?",
|
||||
(res[3:],))
|
||||
|
|
Loading…
Reference in a new issue