From 7ec3f1ecc0e17e9f92daf3d40946fa7822c2fe9c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 17 May 2020 20:50:34 +1000 Subject: [PATCH] fix syncing --- pylib/anki/models.py | 2 -- pylib/anki/sync.py | 10 +++++----- rslib/src/decks/mod.rs | 1 - 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pylib/anki/models.py b/pylib/anki/models.py index 02fe1ae79..a38c5bda6 100644 --- a/pylib/anki/models.py +++ b/pylib/anki/models.py @@ -20,8 +20,6 @@ NoteType = Dict[str, Any] Field = Dict[str, Any] Template = Dict[str, Union[str, int, None]] -# fixme: syncing - class ModelsDictProxy: def __init__(self, col: anki.storage._Collection): diff --git a/pylib/anki/sync.py b/pylib/anki/sync.py index 1def67c89..60be194f1 100644 --- a/pylib/anki/sync.py +++ b/pylib/anki/sync.py @@ -347,7 +347,7 @@ from notes where %s""" mods = [m for m in self.col.models.all() if m["usn"] == -1] for m in mods: m["usn"] = self.maxUsn - self.col.models.save() + self.col.models.update(m, preserve_usn=True) return mods def mergeModels(self, rchg) -> None: @@ -363,7 +363,7 @@ from notes where %s""" raise UnexpectedSchemaChange() if len(l["tmpls"]) != len(r["tmpls"]): raise UnexpectedSchemaChange() - self.col.models.update(r) + self.col.models.update(r, preserve_usn=True) # Decks ########################################################################## @@ -372,11 +372,11 @@ from notes where %s""" decks = [g for g in self.col.decks.all() if g["usn"] == -1] for g in decks: g["usn"] = self.maxUsn + self.col.decks.update(g, preserve_usn=True) dconf = [g for g in self.col.decks.all_config() if g["usn"] == -1] for g in dconf: g["usn"] = self.maxUsn self.col.decks.update_config(g, preserve_usn=True) - self.col.decks.save() return [decks, dconf] def mergeDecks(self, rchg) -> None: @@ -388,7 +388,7 @@ from notes where %s""" # if missing locally or server is newer, update if not l or r["mod"] > l["mod"]: - self.col.decks.update(r) + self.col.decks.update(r, preserve_usn=True) for r in rchg[1]: try: l = self.col.decks.get_config(r["id"]) @@ -396,7 +396,7 @@ from notes where %s""" l = None # if missing locally or server is newer, update if not l or r["mod"] > l["mod"]: - self.col.decks.update_config(r) + self.col.decks.update_config(r, preserve_usn=True) # Tags ########################################################################## diff --git a/rslib/src/decks/mod.rs b/rslib/src/decks/mod.rs index d4325deed..1e3f4806e 100644 --- a/rslib/src/decks/mod.rs +++ b/rslib/src/decks/mod.rs @@ -109,7 +109,6 @@ fn invalid_char_for_deck_component(c: char) -> bool { c.is_ascii_control() || c == '"' } -// fixme: need to bump usn on upgrade if we rename fn normalized_deck_name_component(comp: &str) -> Cow { let mut out = normalize_to_nfc(comp); if out.contains(invalid_char_for_deck_component) {