mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
implement full sync downloading
This commit is contained in:
parent
b351946f55
commit
65a718fdbe
2 changed files with 19 additions and 14 deletions
|
@ -1891,19 +1891,18 @@ Couldn't contact Anki Online. Please check your internet connection.""")
|
||||||
ui.utils.showWarning(_(
|
ui.utils.showWarning(_(
|
||||||
"Failed to upload media. Please run 'check media db'."), self)
|
"Failed to upload media. Please run 'check media db'."), self)
|
||||||
|
|
||||||
def fullSyncStarted(self, ret):
|
def fullSyncStarted(self, max):
|
||||||
self.startProgress(max=ret[2])
|
self.startProgress(max=max)
|
||||||
if ret[0] == "fromLocal":
|
|
||||||
s = _("Uploading to server...")
|
|
||||||
else:
|
|
||||||
s = _("Downloading from server...")
|
|
||||||
self.updateProgress(label=s)
|
|
||||||
|
|
||||||
def fullSyncFinished(self):
|
def fullSyncFinished(self):
|
||||||
self.finishProgress()
|
self.finishProgress()
|
||||||
|
|
||||||
def fullSyncProgress(self, val):
|
def fullSyncProgress(self, type, val):
|
||||||
self.updateProgress(value=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
|
# Menu, title bar & status
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
|
@ -42,14 +42,14 @@ class Sync(QThread):
|
||||||
removeHook('fullSyncFinished', self.fullSyncFinished)
|
removeHook('fullSyncFinished', self.fullSyncFinished)
|
||||||
removeHook('fullSyncProgress', self.fullSyncProgress)
|
removeHook('fullSyncProgress', self.fullSyncProgress)
|
||||||
|
|
||||||
def fullSyncStarted(self, ret):
|
def fullSyncStarted(self, max):
|
||||||
self.emit(SIGNAL("fullSyncStarted"), ret)
|
self.emit(SIGNAL("fullSyncStarted"), max)
|
||||||
|
|
||||||
def fullSyncFinished(self):
|
def fullSyncFinished(self):
|
||||||
self.emit(SIGNAL("fullSyncFinished"))
|
self.emit(SIGNAL("fullSyncFinished"))
|
||||||
|
|
||||||
def fullSyncProgress(self, val):
|
def fullSyncProgress(self, type, val):
|
||||||
self.emit(SIGNAL("fullSyncProgress"), val)
|
self.emit(SIGNAL("fullSyncProgress"), type, val)
|
||||||
|
|
||||||
def error(self, error):
|
def error(self, error):
|
||||||
if getattr(error, 'data', None) is None:
|
if getattr(error, 'data', None) is None:
|
||||||
|
@ -119,7 +119,13 @@ class Sync(QThread):
|
||||||
sums = client.summaries()
|
sums = client.summaries()
|
||||||
if client.needFullSync(sums):
|
if client.needFullSync(sums):
|
||||||
self.setStatus(_("Preparing full sync..."), 0)
|
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)
|
self.setStatus(_("Sync complete."), 0)
|
||||||
else:
|
else:
|
||||||
# diff
|
# diff
|
||||||
|
|
Loading…
Reference in a new issue