fix syncing
This commit is contained in:
parent
69537bb748
commit
7ec3f1ecc0
@ -20,8 +20,6 @@ NoteType = Dict[str, Any]
|
|||||||
Field = Dict[str, Any]
|
Field = Dict[str, Any]
|
||||||
Template = Dict[str, Union[str, int, None]]
|
Template = Dict[str, Union[str, int, None]]
|
||||||
|
|
||||||
# fixme: syncing
|
|
||||||
|
|
||||||
|
|
||||||
class ModelsDictProxy:
|
class ModelsDictProxy:
|
||||||
def __init__(self, col: anki.storage._Collection):
|
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]
|
mods = [m for m in self.col.models.all() if m["usn"] == -1]
|
||||||
for m in mods:
|
for m in mods:
|
||||||
m["usn"] = self.maxUsn
|
m["usn"] = self.maxUsn
|
||||||
self.col.models.save()
|
self.col.models.update(m, preserve_usn=True)
|
||||||
return mods
|
return mods
|
||||||
|
|
||||||
def mergeModels(self, rchg) -> None:
|
def mergeModels(self, rchg) -> None:
|
||||||
@ -363,7 +363,7 @@ from notes where %s"""
|
|||||||
raise UnexpectedSchemaChange()
|
raise UnexpectedSchemaChange()
|
||||||
if len(l["tmpls"]) != len(r["tmpls"]):
|
if len(l["tmpls"]) != len(r["tmpls"]):
|
||||||
raise UnexpectedSchemaChange()
|
raise UnexpectedSchemaChange()
|
||||||
self.col.models.update(r)
|
self.col.models.update(r, preserve_usn=True)
|
||||||
|
|
||||||
# Decks
|
# Decks
|
||||||
##########################################################################
|
##########################################################################
|
||||||
@ -372,11 +372,11 @@ from notes where %s"""
|
|||||||
decks = [g for g in self.col.decks.all() if g["usn"] == -1]
|
decks = [g for g in self.col.decks.all() if g["usn"] == -1]
|
||||||
for g in decks:
|
for g in decks:
|
||||||
g["usn"] = self.maxUsn
|
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]
|
dconf = [g for g in self.col.decks.all_config() if g["usn"] == -1]
|
||||||
for g in dconf:
|
for g in dconf:
|
||||||
g["usn"] = self.maxUsn
|
g["usn"] = self.maxUsn
|
||||||
self.col.decks.update_config(g, preserve_usn=True)
|
self.col.decks.update_config(g, preserve_usn=True)
|
||||||
self.col.decks.save()
|
|
||||||
return [decks, dconf]
|
return [decks, dconf]
|
||||||
|
|
||||||
def mergeDecks(self, rchg) -> None:
|
def mergeDecks(self, rchg) -> None:
|
||||||
@ -388,7 +388,7 @@ from notes where %s"""
|
|||||||
|
|
||||||
# if missing locally or server is newer, update
|
# if missing locally or server is newer, update
|
||||||
if not l or r["mod"] > l["mod"]:
|
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]:
|
for r in rchg[1]:
|
||||||
try:
|
try:
|
||||||
l = self.col.decks.get_config(r["id"])
|
l = self.col.decks.get_config(r["id"])
|
||||||
@ -396,7 +396,7 @@ from notes where %s"""
|
|||||||
l = None
|
l = None
|
||||||
# if missing locally or server is newer, update
|
# if missing locally or server is newer, update
|
||||||
if not l or r["mod"] > l["mod"]:
|
if not l or r["mod"] > l["mod"]:
|
||||||
self.col.decks.update_config(r)
|
self.col.decks.update_config(r, preserve_usn=True)
|
||||||
|
|
||||||
# Tags
|
# Tags
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
@ -109,7 +109,6 @@ fn invalid_char_for_deck_component(c: char) -> bool {
|
|||||||
c.is_ascii_control() || c == '"'
|
c.is_ascii_control() || c == '"'
|
||||||
}
|
}
|
||||||
|
|
||||||
// fixme: need to bump usn on upgrade if we rename
|
|
||||||
fn normalized_deck_name_component(comp: &str) -> Cow<str> {
|
fn normalized_deck_name_component(comp: &str) -> Cow<str> {
|
||||||
let mut out = normalize_to_nfc(comp);
|
let mut out = normalize_to_nfc(comp);
|
||||||
if out.contains(invalid_char_for_deck_component) {
|
if out.contains(invalid_char_for_deck_component) {
|
||||||
|
Loading…
Reference in New Issue
Block a user