mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
check download before overwrite
This commit is contained in:
parent
6965a9c102
commit
8fff05618c
1 changed files with 5 additions and 2 deletions
|
@ -509,10 +509,13 @@ class FullSyncer(HttpSyncer):
|
|||
raise Exception("Invalid response code: %s" % resp['status'])
|
||||
tpath = self.col.path + ".tmp"
|
||||
open(tpath, "wb").write(cont)
|
||||
# check the received file is ok
|
||||
d = DB(tpath)
|
||||
assert d.scalar("pragma integrity_check") == "ok"
|
||||
d.close()
|
||||
# overwrite existing collection
|
||||
os.unlink(self.col.path)
|
||||
os.rename(tpath, self.col.path)
|
||||
d = DB(self.col.path)
|
||||
assert d.scalar("pragma integrity_check") == "ok"
|
||||
self.col = None
|
||||
|
||||
def upload(self):
|
||||
|
|
Loading…
Reference in a new issue