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:
Damien Elmes 2011-12-06 23:04:26 +09:00
parent be66c960a9
commit fabec6e920
2 changed files with 6 additions and 7 deletions

View file

@ -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]

View file

@ -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):