Disable caching of get_asset_json if debug mode (#2090)

* Disable caching of get_asset_json if debug mode
This commit is contained in:
Kevin Chung
2022-04-13 18:44:57 -04:00
committed by GitHub
parent ab4dd902c4
commit 4efccfc39f
2 changed files with 10 additions and 3 deletions

View File

@@ -2,7 +2,7 @@ import os
from flask import current_app, url_for
from CTFd.utils import _get_asset_json
from CTFd.utils import get_asset_json
from CTFd.utils.config import ctf_theme
from CTFd.utils.helpers import markup
@@ -13,14 +13,14 @@ class _AssetsWrapper:
manifest = os.path.join(
current_app.root_path, "themes", theme, "static", "manifest.json"
)
return _get_asset_json(path=manifest)
return get_asset_json(path=manifest)
def manifest_css(self):
theme = ctf_theme()
manifest = os.path.join(
current_app.root_path, "themes", theme, "static", "manifest-css.json"
)
return _get_asset_json(path=manifest)
return get_asset_json(path=manifest)
def js(self, asset_key):
asset = self.manifest()[asset_key]

View File

@@ -33,6 +33,13 @@ def _get_asset_json(path):
return json.loads(f.read())
def get_asset_json(path):
# Ignore caching if we are in debug mode
if app.debug:
return _get_asset_json.__wrapped__(path)
return _get_asset_json(path)
@cache.memoize()
def _get_config(key):
config = db.session.execute(