Add confirmation for upload

This commit is contained in:
Damien Elmes 2023-11-07 11:11:07 +10:00
parent 9268dce707
commit 0b8b168df1
2 changed files with 14 additions and 1 deletions

View File

@ -26,6 +26,7 @@ sync-wrong-pass = AnkiWeb ID or password was incorrect; please try again.
sync-resync-required = Please sync again. If this message keeps appearing, please post on the support site. sync-resync-required = Please sync again. If this message keeps appearing, please post on the support site.
sync-must-wait-for-end = Anki is currently syncing. Please wait for the sync to complete, then try again. sync-must-wait-for-end = Anki is currently syncing. Please wait for the sync to complete, then try again.
sync-confirm-empty-download = Local collection has no cards. Download from AnkiWeb? sync-confirm-empty-download = Local collection has no cards. Download from AnkiWeb?
sync-confirm-empty-upload = AnkiWeb collection has no cards. Replace it with local collection?
sync-conflict-explanation = sync-conflict-explanation =
Your decks here and on AnkiWeb differ in such a way that they can't be merged together, so it's necessary to overwrite the decks on one side with the decks from the other. Your decks here and on AnkiWeb differ in such a way that they can't be merged together, so it's necessary to overwrite the decks on one side with the decks from the other.

View File

@ -135,7 +135,7 @@ def full_sync(
if out.required == out.FULL_DOWNLOAD: if out.required == out.FULL_DOWNLOAD:
confirm_full_download(mw, server_usn, on_done) confirm_full_download(mw, server_usn, on_done)
elif out.required == out.FULL_UPLOAD: elif out.required == out.FULL_UPLOAD:
full_upload(mw, server_usn, on_done) confirm_full_upload(mw, server_usn, on_done)
else: else:
button_labels: list[str] = [ button_labels: list[str] = [
tr.sync_upload_to_ankiweb(), tr.sync_upload_to_ankiweb(),
@ -170,6 +170,18 @@ def confirm_full_download(
mw.closeAllWindows(lambda: full_download(mw, server_usn, on_done)) mw.closeAllWindows(lambda: full_download(mw, server_usn, on_done))
def confirm_full_upload(
mw: aqt.main.AnkiQt, server_usn: int, on_done: Callable[[], None]
) -> None:
# confirmation step required, as some users have reported an upload
# happening despite having their AnkiWeb collection not being empty
# (not reproducible - maybe a compiler bug?)
if not askUser(tr.sync_confirm_empty_upload()):
return on_done()
else:
mw.closeAllWindows(lambda: full_upload(mw, server_usn, on_done))
def on_full_sync_timer(mw: aqt.main.AnkiQt, label: str) -> None: def on_full_sync_timer(mw: aqt.main.AnkiQt, label: str) -> None:
progress = mw.col.latest_progress() progress = mw.col.latest_progress()
if not progress.HasField("full_sync"): if not progress.HasField("full_sync"):