Update sync.py
This commit is contained in:
parent
811ae45d58
commit
4c305dff88
@ -10,6 +10,7 @@ import random
|
|||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
from typing import List,Tuple
|
||||||
|
|
||||||
from anki.db import DB, DBError
|
from anki.db import DB, DBError
|
||||||
from anki.utils import ids2str, intTime, platDesc, checksum, devMode
|
from anki.utils import ids2str, intTime, platDesc, checksum, devMode
|
||||||
@ -83,7 +84,7 @@ class Syncer(object):
|
|||||||
for g in self.col.decks.all():
|
for g in self.col.decks.all():
|
||||||
if g['usn'] == -1:
|
if g['usn'] == -1:
|
||||||
return "deck had usn = -1"
|
return "deck had usn = -1"
|
||||||
for t, usn in self.col.tags.allItems():
|
for t, usn in self.allItems():
|
||||||
if usn == -1:
|
if usn == -1:
|
||||||
return "tag had usn = -1"
|
return "tag had usn = -1"
|
||||||
found = False
|
found = False
|
||||||
@ -276,10 +277,12 @@ from notes where %s""" % lim, self.maxUsn)
|
|||||||
|
|
||||||
# Tags
|
# Tags
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
def allItems(self) -> List[Tuple[str, int]]:
|
||||||
|
tags=self.col.db.execute("select tag, usn from tags")
|
||||||
|
return [(tag, int(usn)) for tag,usn in tags]
|
||||||
def getTags(self):
|
def getTags(self):
|
||||||
tags = []
|
tags = []
|
||||||
for t, usn in self.col.tags.allItems():
|
for t, usn in self.allItems():
|
||||||
if usn == -1:
|
if usn == -1:
|
||||||
self.col.tags.tags[t] = self.maxUsn
|
self.col.tags.tags[t] = self.maxUsn
|
||||||
tags.append(t)
|
tags.append(t)
|
||||||
@ -331,7 +334,9 @@ from notes where %s""" % lim, self.maxUsn)
|
|||||||
return self.col.conf
|
return self.col.conf
|
||||||
|
|
||||||
def mergeConf(self, conf):
|
def mergeConf(self, conf):
|
||||||
self.col.backend.set_all_config(json.dumps(conf).encode())
|
for key, value in conf.items():
|
||||||
|
self.col.set_config(key, value)
|
||||||
|
# self.col.backend.set_all_config(json.dumps(conf).encode())
|
||||||
|
|
||||||
# Wrapper for requests that tracks upload/download progress
|
# Wrapper for requests that tracks upload/download progress
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user