implement full sync downloading

This commit is contained in:
Damien Elmes 2009-06-02 03:23:06 +09:00
parent b351946f55
commit 65a718fdbe
2 changed files with 19 additions and 14 deletions

View file

@ -1891,19 +1891,18 @@ Couldn't contact Anki Online. Please check your internet connection.""")
ui.utils.showWarning(_(
"Failed to upload media. Please run 'check media db'."), self)
def fullSyncStarted(self, ret):
self.startProgress(max=ret[2])
if ret[0] == "fromLocal":
s = _("Uploading to server...")
else:
s = _("Downloading from server...")
self.updateProgress(label=s)
def fullSyncStarted(self, max):
self.startProgress(max=max)
def fullSyncFinished(self):
self.finishProgress()
def fullSyncProgress(self, val):
self.updateProgress(value=val)
def fullSyncProgress(self, type, val):
if type == "fromLocal":
s = _("Uploaded %dKB to server...")
else:
s = _("Downloaded %dKB from server...")
self.updateProgress(label=s % (val / 1024), value=val)
# Menu, title bar & status
##########################################################################

View file

@ -42,14 +42,14 @@ class Sync(QThread):
removeHook('fullSyncFinished', self.fullSyncFinished)
removeHook('fullSyncProgress', self.fullSyncProgress)
def fullSyncStarted(self, ret):
self.emit(SIGNAL("fullSyncStarted"), ret)
def fullSyncStarted(self, max):
self.emit(SIGNAL("fullSyncStarted"), max)
def fullSyncFinished(self):
self.emit(SIGNAL("fullSyncFinished"))
def fullSyncProgress(self, val):
self.emit(SIGNAL("fullSyncProgress"), val)
def fullSyncProgress(self, type, val):
self.emit(SIGNAL("fullSyncProgress"), type, val)
def error(self, error):
if getattr(error, 'data', None) is None:
@ -119,7 +119,13 @@ class Sync(QThread):
sums = client.summaries()
if client.needFullSync(sums):
self.setStatus(_("Preparing full sync..."), 0)
client.fullSync()
ret = client.prepareFullSync()
if ret[0] == "fromLocal":
self.setStatus(_("Uploading..."), 0)
client.fullSyncFromLocal(ret[1], ret[2])
else:
self.setStatus(_("Downloading..."), 0)
client.fullSyncFromServer(ret[1], ret[2])
self.setStatus(_("Sync complete."), 0)
else:
# diff