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:
Damien Elmes 2011-01-04 15:51:24 +09:00
parent d717be8849
commit 1f34abc003

View file

@ -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:],))