From 03fc739b3ccf13c054e89ff9f4ce8f2555f204d9 Mon Sep 17 00:00:00 2001 From: axolotle Date: Thu, 9 Nov 2023 15:49:19 +0100 Subject: [PATCH] domain: add _get_raw_domain_settings to read settings directly + use it in app_info to avoid infinite recursion --- src/app.py | 4 ++-- src/domain.py | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/app.py b/src/app.py index 482e880e4..8e3f685ad 100644 --- a/src/app.py +++ b/src/app.py @@ -128,7 +128,7 @@ def app_info(app, full=False, upgradable=False): """ Get info for a specific app """ - from yunohost.domain import domain_config_get + from yunohost.domain import _get_raw_domain_settings from yunohost.permission import user_permission_list _assert_is_installed(app) @@ -229,7 +229,7 @@ def app_info(app, full=False, upgradable=False): if ret["is_webapp"]: ret["is_default"] = ( - domain_config_get(settings["domain"], "feature.app.default_app") == app + _get_raw_domain_settings(settings["domain"]).get("default_app") == app ) ret["supports_change_url"] = os.path.exists( diff --git a/src/domain.py b/src/domain.py index f1bbf474d..2b029bd04 100644 --- a/src/domain.py +++ b/src/domain.py @@ -617,6 +617,19 @@ def domain_url_available(domain, path): return len(_get_conflicting_apps(domain, path)) == 0 +def _get_raw_domain_settings(domain): + """Get domain settings directly from file. + Be carefull, domain settings are saved in `"diff"` mode (i.e. default settings are not saved) + so the file may be completely empty + """ + _assert_domain_exists(domain) + path = DomainConfigPanel.save_path_tpl.format(entity=domain) + if os.path.exists(path): + return read_yaml(path) + + return {} + + def domain_config_get(domain, key="", full=False, export=False): """ Display a domain configuration @@ -738,7 +751,7 @@ class DomainConfigPanel(ConfigPanel): if next_settings.get("recovery_password", None): domain_dyndns_set_recovery_password( - self.entity, form["recovery_password"] + self.entity, next_settings["recovery_password"] ) portal_options = [ @@ -749,8 +762,7 @@ class DomainConfigPanel(ConfigPanel): "portal_theme", ] if _get_parent_domain_of(self.entity, topest=True) is None and any( - option in next_settings - for option in portal_options + option in next_settings for option in portal_options ): from yunohost.portal import PORTAL_SETTINGS_DIR