diff --git a/ftl/core/sync.ftl b/ftl/core/sync.ftl index 8eac89f5d..32aafa930 100644 --- a/ftl/core/sync.ftl +++ b/ftl/core/sync.ftl @@ -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-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-upload = AnkiWeb collection has no cards. Replace it with local collection? 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. diff --git a/qt/aqt/sync.py b/qt/aqt/sync.py index 051baa483..9c776dddd 100644 --- a/qt/aqt/sync.py +++ b/qt/aqt/sync.py @@ -135,7 +135,7 @@ def full_sync( if out.required == out.FULL_DOWNLOAD: confirm_full_download(mw, server_usn, on_done) elif out.required == out.FULL_UPLOAD: - full_upload(mw, server_usn, on_done) + confirm_full_upload(mw, server_usn, on_done) else: button_labels: list[str] = [ tr.sync_upload_to_ankiweb(), @@ -170,6 +170,18 @@ def confirm_full_download( 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: progress = mw.col.latest_progress() if not progress.HasField("full_sync"):