make sure to close temp file fds, add full sync to sync()

This commit is contained in:
Damien Elmes 2009-06-05 15:16:11 +09:00
parent dd9ba0e833
commit f5facee398

View file

@ -68,6 +68,9 @@ class SyncTools(object):
if not self.prepareSync():
return
sums = self.summaries()
if self.needFullSync(sums):
self.fullSync()
else:
payload = self.genPayload(sums)
res = self.server.applyPayload(payload)
self.applyPayloadReply(res)
@ -989,6 +992,7 @@ and cards.id in %s""" % ids2str([c[0] for c in cards])))
# wait for reply
dst.close()
tmp.close()
os.close(fd)
errcode, errmsg, headers = h.getreply()
assert errcode == 200
finally:
@ -1014,6 +1018,7 @@ and cards.id in %s""" % ids2str([c[0] for c in cards])))
runHook("fullSyncProgress", "fromServer", cnt)
src.close()
tmp.close()
os.close(fd)
# if we were successful, overwrite old deck
os.unlink(path)
os.rename(tmpname, path)