disable media get / posts when collection closed

https://forums.ankiweb.net/t/countdown-to-events-exams-addon-official-thread/1093/4?u=dae
This commit is contained in:
Damien Elmes 2020-08-04 09:54:17 +10:00
parent b363aaf401
commit 440aa129d9

View file

@ -124,6 +124,10 @@ def allroutes(pathin):
try:
if flask.request.method == "POST":
if not aqt.mw.col:
print(f"collection not open, ignore request for {path}")
return flask.make_response(f"Collection not open", HTTPStatus.NOT_FOUND)
if path == "graphData":
body = request.data
data = graph_data(aqt.mw.col, **from_json_bytes(body))
@ -196,6 +200,13 @@ def _redirectWebExports(path):
if re.fullmatch(pattern, subPath):
return addMgr.addonsFolder(), addonPath
print(f"couldn't locate item in add-on folder {path}")
return None
if not aqt.mw.col:
print(f"collection not open, ignore request for {path}")
return None
return aqt.mw.col.media.dir(), path