Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor check_database_state function to accept request method and p… #1944

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading