From 662c332ffe0ae9cd451775ff101e428f7edf45d4 Mon Sep 17 00:00:00 2001 From: florian Date: Sat, 25 May 2024 21:06:24 +0200 Subject: [PATCH] ui - avoid DB calls on static files --- src/ui/main.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ui/main.py b/src/ui/main.py index eac6d42dc..09c569624 100755 --- a/src/ui/main.py +++ b/src/ui/main.py @@ -445,15 +445,17 @@ def handle_csrf_error(_): @app.before_request def before_request(): - if not app.config["DB"].readonly: - try: - app.config["DB"].test_write() - except BaseException: - app.config["DB"].readonly = True - db_user = app.config["DB"].get_ui_user() - if db_user: - app.config["USER"] = User(**db_user) + if not request.path.startswith(("/css", "/images", "/js", "/json", "/webfonts")): + if not app.config["DB"].readonly: + try: + app.config["DB"].test_write() + except BaseException: + app.config["DB"].readonly = True + + db_user = app.config["DB"].get_ui_user() + if db_user: + app.config["USER"] = User(**db_user) app.config["SCRIPT_NONCE"] = sha256(urandom(32)).hexdigest()