From a11654e0cfb4cb72ddb6514d39eaa7782c608e18 Mon Sep 17 00:00:00 2001 From: Kayou Date: Wed, 6 May 2020 11:57:28 +0200 Subject: [PATCH 1/3] [fix] domain remove if an app without a domain is installed --- src/yunohost/domain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index f1dcefba9..0c1e58e54 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -180,7 +180,7 @@ def domain_remove(operation_logger, domain, force=False): # Check if apps are installed on the domain app_settings = [_get_app_settings(app) for app in _installed_apps()] - if any(s["domain"] == domain for s in app_settings): + if any("domain" in s and s["domain"] == domain for s in app_settings): raise YunohostError('domain_uninstall_app_first') operation_logger.start() From 9e86014636902ec5267c1f44692a26066b087718 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Wed, 6 May 2020 20:20:38 +0200 Subject: [PATCH 2/3] [mod] improve error message when apps are still installed on a domain --- locales/en.json | 2 +- src/yunohost/domain.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/locales/en.json b/locales/en.json index 25712e8cd..5d49baf23 100644 --- a/locales/en.json +++ b/locales/en.json @@ -271,7 +271,7 @@ "domain_dyndns_root_unknown": "Unknown DynDNS root domain", "domain_exists": "The domain already exists", "domain_hostname_failed": "Could not set new hostname. This might cause an issue later (it might be fine).", - "domain_uninstall_app_first": "One or more apps are installed on this domain. Please uninstall them before proceeding to domain removal", + "domain_uninstall_app_first": "Those applications are still installed on your domain: {apps}. Please uninstall them before proceeding to domain removal", "domain_unknown": "Unknown domain", "domains_available": "Available domains:", "done": "Done", diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index 0c1e58e54..2440d8702 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -179,9 +179,15 @@ def domain_remove(operation_logger, domain, force=False): raise YunohostError('domain_cannot_remove_main_add_new_one', domain=domain) # Check if apps are installed on the domain - app_settings = [_get_app_settings(app) for app in _installed_apps()] - if any("domain" in s and s["domain"] == domain for s in app_settings): - raise YunohostError('domain_uninstall_app_first') + apps_on_that_domain = [] + + for app in _installed_apps(): + settings = _get_app_settings(app) + if settings.get("domain") == domain: + apps_on_that_domain.append("%s (on https://%s%s)" % (app, domain, settings.get("path"))) + + if apps_on_that_domain: + raise YunohostError('domain_uninstall_app_first', apps=", ".join(apps_on_that_domain)) operation_logger.start() ldap = _get_ldap_interface() From 0b035782d07a8c25c355eee8a20cfd2b6842e608 Mon Sep 17 00:00:00 2001 From: Bram Date: Wed, 6 May 2020 20:35:32 +0200 Subject: [PATCH 3/3] Update src/yunohost/domain.py Co-authored-by: Alexandre Aubin --- src/yunohost/domain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index 2440d8702..700505d54 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -184,7 +184,7 @@ def domain_remove(operation_logger, domain, force=False): for app in _installed_apps(): settings = _get_app_settings(app) if settings.get("domain") == domain: - apps_on_that_domain.append("%s (on https://%s%s)" % (app, domain, settings.get("path"))) + apps_on_that_domain.append("%s (on https://%s%s)" % (app, domain, settings["path"]) if "path" in settings else app) if apps_on_that_domain: raise YunohostError('domain_uninstall_app_first', apps=", ".join(apps_on_that_domain))