mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
ensure pending deck/tag/note type changes flushed before searching
This commit is contained in:
parent
2c99a4203f
commit
ab6eeb5882
1 changed files with 10 additions and 5 deletions
|
@ -216,17 +216,20 @@ crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""",
|
||||||
json.dumps(self.conf),
|
json.dumps(self.conf),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def flush_all_changes(self, mod: Optional[int] = None):
|
||||||
|
self.models.flush()
|
||||||
|
self.decks.flush()
|
||||||
|
self.tags.flush()
|
||||||
|
if self.db.mod:
|
||||||
|
self.flush(mod)
|
||||||
|
|
||||||
def save(
|
def save(
|
||||||
self, name: Optional[str] = None, mod: Optional[int] = None, trx: bool = True
|
self, name: Optional[str] = None, mod: Optional[int] = None, trx: bool = True
|
||||||
) -> None:
|
) -> None:
|
||||||
"Flush, commit DB, and take out another write lock if trx=True."
|
"Flush, commit DB, and take out another write lock if trx=True."
|
||||||
# let the managers conditionally flush
|
self.flush_all_changes(mod)
|
||||||
self.models.flush()
|
|
||||||
self.decks.flush()
|
|
||||||
self.tags.flush()
|
|
||||||
# and flush deck + bump mod if db has been changed
|
# and flush deck + bump mod if db has been changed
|
||||||
if self.db.mod:
|
if self.db.mod:
|
||||||
self.flush(mod=mod)
|
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
self.db.mod = False
|
self.db.mod = False
|
||||||
if trx:
|
if trx:
|
||||||
|
@ -630,9 +633,11 @@ where c.nid = n.id and c.id in %s group by nid"""
|
||||||
def find_cards(
|
def find_cards(
|
||||||
self, query: str, order: Union[bool, str, int] = False, reverse: bool = False,
|
self, query: str, order: Union[bool, str, int] = False, reverse: bool = False,
|
||||||
) -> Sequence[int]:
|
) -> Sequence[int]:
|
||||||
|
self.flush_all_changes()
|
||||||
return self.backend.search_cards(query, order, reverse)
|
return self.backend.search_cards(query, order, reverse)
|
||||||
|
|
||||||
def find_notes(self, query: str) -> Sequence[int]:
|
def find_notes(self, query: str) -> Sequence[int]:
|
||||||
|
self.flush_all_changes()
|
||||||
return self.backend.search_notes(query)
|
return self.backend.search_notes(query)
|
||||||
|
|
||||||
def findReplace(
|
def findReplace(
|
||||||
|
|
Loading…
Reference in a new issue