From a16bd9434122e13c6ff0ade866eb450d2bb0f5fb Mon Sep 17 00:00:00 2001 From: Sudarshan Gaikaiwari Date: Wed, 21 Feb 2018 07:16:52 -0600 Subject: [PATCH 1/3] Expose Anki sync via AnkiConnect --- AnkiConnect.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/AnkiConnect.py b/AnkiConnect.py index e9cabcd..5280dd4 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -947,10 +947,14 @@ class AnkiBridge: timer.timeout.connect(exitAnki) timer.start(1000) # 1s should be enough to allow the response to be sent. + def sync(self): + self.window()._sync() + # # AnkiConnect # + class AnkiConnect: def __init__(self): self.anki = AnkiBridge() @@ -1281,6 +1285,11 @@ class AnkiConnect: def notesInfo(self, notes): return self.anki.notesInfo(notes) + @webApi() + def sync(self): + return self.anki.sync() + + # # Entry # From 834b5ace7b70454444114f6c9f1c5bae7a506000 Mon Sep 17 00:00:00 2001 From: Sudarshan Gaikaiwari Date: Wed, 21 Feb 2018 07:28:28 -0600 Subject: [PATCH 2/3] Calls onSync to prevent the corruption of collection message --- AnkiConnect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AnkiConnect.py b/AnkiConnect.py index 5280dd4..5a96d47 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -948,7 +948,7 @@ class AnkiBridge: timer.start(1000) # 1s should be enough to allow the response to be sent. def sync(self): - self.window()._sync() + self.window().onSync() # # AnkiConnect From 8d1fb1989bd9c01cb173a15f7ffa413c8853f55e Mon Sep 17 00:00:00 2001 From: Sudarshan Gaikaiwari Date: Wed, 21 Feb 2018 11:01:37 -0600 Subject: [PATCH 3/3] updates README.md --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 5b51e71..8c8cad4 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,27 @@ guarantee that your application continues to function properly in the future. } ``` +* **sync** + + Synchronizes the local anki collections with ankiweb. + + *Sample request*: + ```json + { + "action": "sync", + "version": 5 + + } + ``` + + *Sample result*: + ```json + { + "result": null, + "error": null + } + + * **multi** Performs multiple actions in one request, returning an array with the response of each action (in the given order).