mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Use backend filter for findDupes and handle excep.
This commit is contained in:
parent
d33442f901
commit
423d7e5098
2 changed files with 8 additions and 5 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Optional, Set
|
||||
from typing import TYPE_CHECKING, Optional, Set, Tuple
|
||||
|
||||
from anki.hooks import *
|
||||
from anki.utils import ids2str, splitFields, stripHTMLMedia
|
||||
|
@ -71,9 +71,7 @@ def findDupes(
|
|||
col: Collection, fieldName: str, search: str = ""
|
||||
) -> List[Tuple[Any, List]]:
|
||||
# limit search to notes with applicable field name
|
||||
if search:
|
||||
search = "(" + search + ") "
|
||||
search += '"%s:*"' % fieldName.replace('"', '"')
|
||||
search = col.search_string(searches=[search], field_name=fieldName)
|
||||
# go through notes
|
||||
vals: Dict[str, List[int]] = {}
|
||||
dupes = []
|
||||
|
|
|
@ -1688,7 +1688,12 @@ where id in %s"""
|
|||
|
||||
def duplicatesReport(self, web, fname, search, frm, web_context):
|
||||
self.mw.progress.start()
|
||||
res = self.mw.col.findDupes(fname, search)
|
||||
try:
|
||||
res = self.mw.col.findDupes(fname, search)
|
||||
except InvalidInput as e:
|
||||
self.mw.progress.finish()
|
||||
show_invalid_search_error(e)
|
||||
return
|
||||
if not self._dupesButton:
|
||||
self._dupesButton = b = frm.buttonBox.addButton(
|
||||
tr(TR.BROWSING_TAG_DUPLICATES), QDialogButtonBox.ActionRole
|
||||
|
|
Loading…
Reference in a new issue