mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -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 __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Optional, Set
|
from typing import TYPE_CHECKING, Optional, Set, Tuple
|
||||||
|
|
||||||
from anki.hooks import *
|
from anki.hooks import *
|
||||||
from anki.utils import ids2str, splitFields, stripHTMLMedia
|
from anki.utils import ids2str, splitFields, stripHTMLMedia
|
||||||
|
@ -71,9 +71,7 @@ def findDupes(
|
||||||
col: Collection, fieldName: str, search: str = ""
|
col: Collection, fieldName: str, search: str = ""
|
||||||
) -> List[Tuple[Any, List]]:
|
) -> List[Tuple[Any, List]]:
|
||||||
# limit search to notes with applicable field name
|
# limit search to notes with applicable field name
|
||||||
if search:
|
search = col.search_string(searches=[search], field_name=fieldName)
|
||||||
search = "(" + search + ") "
|
|
||||||
search += '"%s:*"' % fieldName.replace('"', '"')
|
|
||||||
# go through notes
|
# go through notes
|
||||||
vals: Dict[str, List[int]] = {}
|
vals: Dict[str, List[int]] = {}
|
||||||
dupes = []
|
dupes = []
|
||||||
|
|
|
@ -1688,7 +1688,12 @@ where id in %s"""
|
||||||
|
|
||||||
def duplicatesReport(self, web, fname, search, frm, web_context):
|
def duplicatesReport(self, web, fname, search, frm, web_context):
|
||||||
self.mw.progress.start()
|
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:
|
if not self._dupesButton:
|
||||||
self._dupesButton = b = frm.buttonBox.addButton(
|
self._dupesButton = b = frm.buttonBox.addButton(
|
||||||
tr(TR.BROWSING_TAG_DUPLICATES), QDialogButtonBox.ActionRole
|
tr(TR.BROWSING_TAG_DUPLICATES), QDialogButtonBox.ActionRole
|
||||||
|
|
Loading…
Reference in a new issue