From f6ddcd81df241237d202fafb988bb273186a09cd Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 15 Feb 2020 17:48:35 +1000 Subject: [PATCH] fix sync deauth --- pylib/anki/media.py | 3 +++ qt/aqt/preferences.py | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pylib/anki/media.py b/pylib/anki/media.py index c19a9831b..b0e4bb224 100644 --- a/pylib/anki/media.py +++ b/pylib/anki/media.py @@ -79,6 +79,9 @@ class MediaManager: def dir(self) -> Any: return self._dir + def force_resync(self) -> None: + os.unlink(media_paths_from_col_path(self.col.path)[1]) + # File manipulation ########################################################################## diff --git a/qt/aqt/preferences.py b/qt/aqt/preferences.py index 7d964f746..8da87aa7b 100644 --- a/qt/aqt/preferences.py +++ b/qt/aqt/preferences.py @@ -10,7 +10,7 @@ import aqt from anki.lang import _ from aqt import AnkiQt from aqt.qt import * -from aqt.utils import askUser, openHelp, showInfo +from aqt.utils import askUser, openHelp, showInfo, showWarning class Preferences(QDialog): @@ -196,9 +196,12 @@ Not currently enabled; click the sync button in the main window to enable.""" ) ) - def onSyncDeauth(self): + def onSyncDeauth(self) -> None: + if self.mw.media_syncer.is_syncing(): + showWarning("Can't log out while sync in progress.") + return self.prof["syncKey"] = None - self.mw.col.media.forceResync() + self.mw.col.media.force_resync() self._hideAuth() def updateNetwork(self):