Update sync.py
This commit is contained in:
parent
811ae45d58
commit
4c305dff88
@ -10,6 +10,7 @@ import random
|
||||
import requests
|
||||
import json
|
||||
import os
|
||||
from typing import List,Tuple
|
||||
|
||||
from anki.db import DB, DBError
|
||||
from anki.utils import ids2str, intTime, platDesc, checksum, devMode
|
||||
@ -83,7 +84,7 @@ class Syncer(object):
|
||||
for g in self.col.decks.all():
|
||||
if g['usn'] == -1:
|
||||
return "deck had usn = -1"
|
||||
for t, usn in self.col.tags.allItems():
|
||||
for t, usn in self.allItems():
|
||||
if usn == -1:
|
||||
return "tag had usn = -1"
|
||||
found = False
|
||||
@ -276,10 +277,12 @@ from notes where %s""" % lim, self.maxUsn)
|
||||
|
||||
# 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):
|
||||
tags = []
|
||||
for t, usn in self.col.tags.allItems():
|
||||
for t, usn in self.allItems():
|
||||
if usn == -1:
|
||||
self.col.tags.tags[t] = self.maxUsn
|
||||
tags.append(t)
|
||||
@ -331,7 +334,9 @@ from notes where %s""" % lim, self.maxUsn)
|
||||
return self.col.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
|
||||
##########################################################################
|
||||
|
||||
Loading…
Reference in New Issue
Block a user