mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
more sync resuming changes
The server now returns the next usn after every addFiles(), so an interrupted upload doesn't cause the uploaded material to be sent back down.
This commit is contained in:
parent
be66c960a9
commit
fabec6e920
2 changed files with 6 additions and 7 deletions
|
@ -264,11 +264,12 @@ If the same name exists, compare checksums."""
|
|||
cnt = 0
|
||||
files = {}
|
||||
cur = self.db.execute(
|
||||
"select fname from log where type = ? limit 300", MEDIA_ADD)
|
||||
"select fname from log where type = ?", MEDIA_ADD)
|
||||
fnames = []
|
||||
while 1:
|
||||
fname = cur.fetchone()
|
||||
if not fname:
|
||||
# add a flag so the server knows it can clean up
|
||||
z.writestr("_finished", "")
|
||||
break
|
||||
fname = fname[0]
|
||||
|
|
10
anki/sync.py
10
anki/sync.py
|
@ -570,15 +570,13 @@ class MediaSyncer(object):
|
|||
while 1:
|
||||
runHook("sync", "streamMedia")
|
||||
zip, fnames = self.files()
|
||||
if not fnames:
|
||||
# finished
|
||||
break
|
||||
usn = self.server.addFiles(zip=zip)
|
||||
# after server has replied, safe to remove from log
|
||||
self.col.media.forgetAdded(fnames)
|
||||
# when server has run out of files, it returns bumped usn
|
||||
if usn is not False:
|
||||
break
|
||||
# update usn from addFiles() and cached mtime
|
||||
self.col.media.setUsn(usn)
|
||||
#self.col.media.syncMod()
|
||||
self.col.media.setUsn(usn)
|
||||
return "success"
|
||||
|
||||
def removed(self):
|
||||
|
|
Loading…
Reference in a new issue