fix syncing
This commit is contained in:
parent
69537bb748
commit
7ec3f1ecc0
@ -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):
|
||||
|
@ -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
|
||||
##########################################################################
|
||||
|
@ -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<str> {
|
||||
let mut out = normalize_to_nfc(comp);
|
||||
if out.contains(invalid_char_for_deck_component) {
|
||||
|
Loading…
Reference in New Issue
Block a user