mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
ignore broken reset hooks in database check
ideally the original code should be correctly cleaning up the hooks, but if it does not, then we don't want to repeatedly present the user with confusing errors when they try to check their database is ok.
This commit is contained in:
parent
d6d5677fa8
commit
a6c34fd79f
2 changed files with 21 additions and 3 deletions
|
@ -25,13 +25,21 @@ def runHook(hook, *args):
|
|||
hook = _hooks.get(hook, None)
|
||||
if hook:
|
||||
for func in hook:
|
||||
try:
|
||||
func(*args)
|
||||
except:
|
||||
hook.remove(func)
|
||||
raise
|
||||
|
||||
def runFilter(hook, arg, *args):
|
||||
hook = _hooks.get(hook, None)
|
||||
if hook:
|
||||
for func in hook:
|
||||
try:
|
||||
arg = func(arg, *args)
|
||||
except:
|
||||
hook.remove(func)
|
||||
raise
|
||||
return arg
|
||||
|
||||
def addHook(hook, func):
|
||||
|
|
10
aqt/main.py
10
aqt/main.py
|
@ -1054,7 +1054,17 @@ will be lost. Continue?"""))
|
|||
showText(ret)
|
||||
else:
|
||||
tooltip(ret)
|
||||
|
||||
# if an error has directed the user to check the database,
|
||||
# silently clean up any broken reset hooks which distract from
|
||||
# the underlying issue
|
||||
while True:
|
||||
try:
|
||||
self.reset()
|
||||
break
|
||||
except Exception as e:
|
||||
print("swallowed exception in reset hook:", e)
|
||||
continue
|
||||
return ret
|
||||
|
||||
def onCheckMediaDB(self):
|
||||
|
|
Loading…
Reference in a new issue