diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py
index d09158bb6..dffd61a40 100755
--- a/ankiqt/ui/main.py
+++ b/ankiqt/ui/main.py
@@ -2171,6 +2171,7 @@ it to your friends.
self.connect(self.syncThread, SIGNAL("fullSyncProgress"), self.fullSyncProgress)
self.connect(self.syncThread, SIGNAL("badUserPass"), self.badUserPass)
self.connect(self.syncThread, SIGNAL("syncConflicts"), self.onConflict)
+ self.connect(self.syncThread, SIGNAL("syncClobber"), self.onClobber)
self.syncThread.start()
self.switchToWelcomeScreen()
self.setEnabled(False)
@@ -2205,6 +2206,21 @@ you want to do?""" % deckName),
else:
self.syncThread.conflictResolution = "cancel"
+ def onClobber(self, deckName):
+ diag = ui.utils.askUserDialog(_("""\
+You are about to upload %s
+to AnkiOnline. This will overwrite
+the online version if one exists.
+Are you sure?""" % deckName),
+ [_("Overwrite"),
+ _("Cancel")])
+ diag.setDefault(1)
+ ret = diag.run()
+ if ret == _("Overwrite"):
+ self.syncThread.clobberChoice = "overwrite"
+ else:
+ self.syncThread.clobberChoice = "cancel"
+
def onSyncFinished(self):
"Reopen after sync finished."
self.mainWin.buttonStack.show()
@@ -2231,18 +2247,6 @@ you want to do?""" % deckName),
def selectSyncDeck(self, decks, create=True):
name = ui.sync.DeckChooser(self, decks, create).getName()
- if self.syncName != name:
- diag = ui.utils.askUserDialog(_("""\
-Really overwrite the online version?
-There is no way to undo this.
-
-If you want to download an online deck to
-your computer, use File>Download>Personal Deck
-instead."""),
- ["Overwrite", "Cancel"])
- diag.setDefault(1)
- if diag.run() == "Cancel":
- name = None
self.syncName = name
if name:
# name chosen
@@ -2250,6 +2254,7 @@ instead."""),
self.syncDeck(create=True, interactive=False, onlyMerge=onlyMerge)
else:
if not create:
+ self.syncFinished = True
self.cleanNewDeck()
else:
self.onSyncFinished()
diff --git a/ankiqt/ui/sync.py b/ankiqt/ui/sync.py
index 6ab4ab06c..ff94b6d77 100755
--- a/ankiqt/ui/sync.py
+++ b/ankiqt/ui/sync.py
@@ -177,8 +177,21 @@ class Sync(QThread):
client.remoteTime = 0
elif self.conflictResolution == "keepRemote":
client.localTime = 0
+ lastSync = self.deck.lastSync
ret = client.prepareFullSync()
if ret[0] == "fromLocal":
+ if not self.conflictResolution:
+ if lastSync <= 0:
+ self.clobberChoice = None
+ self.emit(SIGNAL("syncClobber"), syncName)
+ while not self.clobberChoice:
+ time.sleep(0.2)
+ if self.clobberChoice == "cancel":
+ self.deck.close()
+ if not deck:
+ # alert we're finished early
+ self.emit(SIGNAL("syncFinished"))
+ return
self.setStatus(_("Uploading..."), 0)
client.fullSyncFromLocal(ret[1], ret[2])
else: