diff --git a/frappe/auth.py b/frappe/auth.py index 3a840ee23d..f7ff6f0fe5 100644 --- a/frappe/auth.py +++ b/frappe/auth.py @@ -8,7 +8,6 @@ import frappe.utils import frappe.utils.user from frappe import _ from frappe.core.doctype.activity_log.activity_log import add_authentication_log -from frappe.modules.patch_handler import check_session_stopped from frappe.sessions import Session, clear_sessions, delete_session from frappe.translate import get_language from frappe.twofactor import ( @@ -42,9 +41,6 @@ class HTTPRequest: # write out latest cookies frappe.local.cookie_manager.init_cookies() - # check session status - check_session_stopped() - @property def domain(self): if not getattr(self, "_domain", None): diff --git a/frappe/model/sync.py b/frappe/model/sync.py index df3999054a..1eab050663 100644 --- a/frappe/model/sync.py +++ b/frappe/model/sync.py @@ -8,17 +8,17 @@ import os import frappe from frappe.modules.import_file import import_file_by_path -from frappe.modules.patch_handler import block_user +from frappe.modules.patch_handler import _patch_mode from frappe.utils import update_progress_bar def sync_all(force=0, reset_permissions=False): - block_user(True) + _patch_mode(True) for app in frappe.get_installed_apps(): sync_for(app, force, reset_permissions=reset_permissions) - block_user(False) + _patch_mode(False) frappe.clear_cache() diff --git a/frappe/modules/patch_handler.py b/frappe/modules/patch_handler.py index f389312a4f..d5a37f52a5 100644 --- a/frappe/modules/patch_handler.py +++ b/frappe/modules/patch_handler.py @@ -154,7 +154,7 @@ def run_single(patchmodule=None, method=None, methodargs=None, force=False): def execute_patch(patchmodule, method=None, methodargs=None): """execute the patch""" - block_user(True) + _patch_mode(True) if patchmodule.startswith("execute:"): has_patch_file = False @@ -197,7 +197,7 @@ def execute_patch(patchmodule, method=None, methodargs=None): else: frappe.db.commit() end_time = time.time() - block_user(False) + _patch_mode(False) print(f"Success: Done in {round(end_time - start_time, 3)}s") return True @@ -216,18 +216,7 @@ def executed(patchmodule): return frappe.db.get_value("Patch Log", {"patch": patchmodule}) -def block_user(block, msg=None): +def _patch_mode(enable): """stop/start execution till patch is run""" - frappe.local.flags.in_patch = block - frappe.db.begin() - if not msg: - msg = "Patches are being executed in the system. Please try again in a few moments." - frappe.db.set_global("__session_status", block and "stop" or None) - frappe.db.set_global("__session_status_message", block and msg or None) + frappe.local.flags.in_patch = enable frappe.db.commit() - - -def check_session_stopped(): - if frappe.db.get_global("__session_status") == "stop": - frappe.msgprint(frappe.db.get_global("__session_status_message")) - raise frappe.SessionStopped("Session Stopped")