Skip to content

Commit

Permalink
Merge pull request #1944 from bunkerity/dev
Browse files Browse the repository at this point in the history
Refactor check_database_state function to accept request method and p…
  • Loading branch information
TheophileDiot authored Jan 24, 2025
2 parents d745bac + 6965a15 commit d7314be
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def update_latest_stable_release():
DATA["LATEST_VERSION"] = get_latest_stable_release()


def check_database_state():
def check_database_state(request_method: str, request_path: str):
DATA.load_from_file()
if (
DB.database_uri
Expand Down Expand Up @@ -293,8 +293,8 @@ def check_database_state():
elif (
DB.database_uri
and not DATA.get("READONLY_MODE", False)
and request.method == "POST"
and not ("/totp" in request.path or "/login" in request.path or request.path.startswith("/plugins/upload"))
and request_method == "POST"
and not ("/totp" in request_path or "/login" in request_path or request_path.startswith("/plugins/upload"))
):
try:
DB.test_write()
Expand Down Expand Up @@ -341,7 +341,7 @@ def before_request():
DATA["LATEST_VERSION_LAST_CHECK"] = datetime.now().astimezone().isoformat()
Thread(target=update_latest_stable_release).start()

Thread(target=check_database_state).start()
Thread(target=check_database_state, args=(request.method, request.path)).start()

DB.readonly = DATA.get("READONLY_MODE", False)

Expand Down

0 comments on commit d7314be

Please sign in to comment.