prevent new users from downloading accidentally
This commit is contained in:
parent
18a7fb9dcd
commit
d976bf913e
@ -634,6 +634,7 @@ class FullSyncer(HttpSyncer):
|
||||
|
||||
def download(self):
|
||||
runHook("sync", "download")
|
||||
localNotEmpty = self.col.db.scalar("select 1 from cards")
|
||||
self.col.close()
|
||||
cont = self.req("download")
|
||||
tpath = self.col.path + ".tmp"
|
||||
@ -644,7 +645,12 @@ class FullSyncer(HttpSyncer):
|
||||
# check the received file is ok
|
||||
d = DB(tpath)
|
||||
assert d.scalar("pragma integrity_check") == "ok"
|
||||
remoteEmpty = not d.scalar("select 1 from cards")
|
||||
d.close()
|
||||
# accidental clobber?
|
||||
if localNotEmpty and remoteEmpty:
|
||||
os.unlink(tpath)
|
||||
return "downloadClobber"
|
||||
# overwrite existing collection
|
||||
os.unlink(self.col.path)
|
||||
os.rename(tpath, self.col.path)
|
||||
|
@ -142,6 +142,8 @@ sync again to correct the issue."""))
|
||||
pass
|
||||
elif evt == "fullSync":
|
||||
self._confirmFullSync()
|
||||
elif evt == "downloadClobber":
|
||||
showInfo(_("Your AnkiWeb collection does not contain any cards. Please sync again and choose 'Upload' instead."))
|
||||
elif evt == "send":
|
||||
# posted events not guaranteed to arrive in order
|
||||
self.sentBytes = max(self.sentBytes, int(args[0]))
|
||||
@ -431,7 +433,10 @@ class SyncThread(QThread):
|
||||
if not self.client.upload():
|
||||
self.fireEvent("upbad")
|
||||
else:
|
||||
self.client.download()
|
||||
ret = self.client.download()
|
||||
if ret == "downloadClobber":
|
||||
self.fireEvent(ret)
|
||||
return
|
||||
except Exception as e:
|
||||
if "sync cancelled" in str(e):
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user