From e100c89ecce846dc5ba8f2035b9bb7229d48c231 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 26 Jun 2025 18:23:38 -0700 Subject: [PATCH] module_loader: Don't load modules again - Only effective once. Second call will skip loading modules. - Helps with privileged daemon where actions might load modules repeatedly. Tests: - Diagnostics/enable/disable for apps bepasty, updates, config, security, nextcloud, homeassistant run fine. - Install/uninstall for bepasty works fine. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Joseph Nuthalapati --- plinth/module_loader.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plinth/module_loader.py b/plinth/module_loader.py index c45888be8..1700832db 100644 --- a/plinth/module_loader.py +++ b/plinth/module_loader.py @@ -7,6 +7,7 @@ import importlib import logging import pathlib import re +import types import django @@ -15,7 +16,7 @@ from plinth.signals import pre_module_loading logger = logging.getLogger(__name__) -loaded_modules = dict() +loaded_modules: dict[str, types.ModuleType] = dict() _modules_to_load = None @@ -31,6 +32,9 @@ def load_modules(): Read names of enabled modules in modules/enabled directory and import them from modules directory. """ + if loaded_modules: + return # Modules have already been loaded + pre_module_loading.send_robust(sender="module_loader") for module_import_path in get_modules_to_load(): module_name = module_import_path.split('.')[-1]