diff --git a/src/ankisyncd/sync.py b/src/ankisyncd/sync.py index f50cbd5..9db4e76 100644 --- a/src/ankisyncd/sync.py +++ b/src/ankisyncd/sync.py @@ -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 ########################################################################## diff --git a/src/ankisyncd/sync_app.py b/src/ankisyncd/sync_app.py index 2147232..edf081d 100644 --- a/src/ankisyncd/sync_app.py +++ b/src/ankisyncd/sync_app.py @@ -178,7 +178,7 @@ class SyncCollectionHandler(Syncer): ] def getTags(self): - return [t for t, usn in self.col.tags.allItems() + return [t for t, usn in self.allItems() if usn >= self.minUsn] class SyncMediaHandler: