From 7f419739725eb58865851f371190ab985c953306 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 27 Jul 2010 23:19:44 +0900 Subject: [PATCH] rework conflict algorithm to detect more conflict cases --- ankiqt/ui/sync.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ankiqt/ui/sync.py b/ankiqt/ui/sync.py index ff94b6d77..b87c57fa6 100755 --- a/ankiqt/ui/sync.py +++ b/ankiqt/ui/sync.py @@ -103,8 +103,8 @@ class Sync(QThread): # multi-mode setup if deck: c = sqlite.connect(deck) - (syncName, localChanged) = c.execute( - "select syncName, modified > lastSync from decks").fetchone() + (syncName, localMod, localSync) = c.execute( + "select syncName, modified, lastSync from decks").fetchone() c.close() if not syncName: return @@ -113,8 +113,8 @@ class Sync(QThread): syncName = self.parent.syncName path = self.parent.deckPath c = sqlite.connect(path) - localChanged = c.execute( - "select modified > lastSync from decks").fetchone()[0] + (localMod, localSync) = c.execute( + "select modified, lastSync from decks").fetchone() c.close() # ensure deck mods cached try: @@ -145,9 +145,12 @@ class Sync(QThread): self.emit(SIGNAL("syncClockOff"), timediff) return # check conflicts - remoteChanged = proxy.hasChanged(syncName) + proxy.deckName = syncName + remoteMod = proxy.modified() + remoteSync = proxy._lastSync() + minSync = min(localSync, remoteSync) self.conflictResolution = None - if localChanged and remoteChanged: + if minSync > 0 and localMod > minSync and remoteMod > minSync: self.emit(SIGNAL("syncConflicts"), syncName) while not self.conflictResolution: time.sleep(0.2) @@ -163,7 +166,6 @@ class Sync(QThread): self.deck = DeckStorage.Deck(path) client = SyncClient(self.deck) client.setServer(proxy) - proxy.deckName = syncName # need to do anything? start = time.time() if client.prepareSync():