From 27611864d2aa1c126598a5c43036d25b1fc907a7 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 27 Nov 2024 14:01:40 +0100 Subject: [PATCH] Fix postinstall in offline context --- src/app.py | 10 +++++++++- src/domain.py | 8 ++++---- src/tools.py | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/app.py b/src/app.py index 6ba3a79910..5c00a15bcd 100644 --- a/src/app.py +++ b/src/app.py @@ -1672,7 +1672,15 @@ def app_ssowatconf(): # Will organize apps by portal domain portal_domains_apps = {domain: {} for domain in portal_domains} - apps_catalog = _load_apps_catalog()["apps"] + + # This check is to prevent an issue during postinstall if the catalog cant + # be initialized (because of offline postinstall) and it's not a big deal + # because there's no app yet (this is only used to get the default logo for + # the app + if os.path.exists("/etc/yunohost/installed"): + apps_catalog = _load_apps_catalog()["apps"] + else: + apps_catalog = {} # New permission system for perm_name, perm_info in all_permissions.items(): diff --git a/src/domain.py b/src/domain.py index 4bc4478c58..96dcb0851a 100644 --- a/src/domain.py +++ b/src/domain.py @@ -636,11 +636,11 @@ def domain_main_domain(operation_logger, new_main_domain=None): if os.path.exists("/etc/yunohost/installed"): regen_conf() - from yunohost.user import _update_admins_group_aliases + from yunohost.user import _update_admins_group_aliases - _update_admins_group_aliases( - old_main_domain=old_main_domain, new_main_domain=new_main_domain - ) + _update_admins_group_aliases( + old_main_domain=old_main_domain, new_main_domain=new_main_domain + ) logger.success(m18n.n("main_domain_changed")) diff --git a/src/tools.py b/src/tools.py index 2efe2fc195..8dd6e413ee 100644 --- a/src/tools.py +++ b/src/tools.py @@ -154,7 +154,7 @@ def tools_postinstall( ) from yunohost.domain import domain_main_domain, domain_add from yunohost.user import user_create, ADMIN_ALIASES - from yunohost.app import _ask_confirmation + from yunohost.app import _ask_confirmation, app_ssowatconf from yunohost.app_catalog import _update_apps_catalog from yunohost.firewall import firewall_upnp