Merge pull request #978 from YunoHost/app-without-domain

[fix] domain remove if an app without a domain is installed
This commit is contained in:
Alexandre Aubin 2020-05-07 00:08:23 +02:00 committed by GitHub
commit 9e096f7825
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View file

@ -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",

View file

@ -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(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["path"]) if "path" in settings else app)
if apps_on_that_domain:
raise YunohostError('domain_uninstall_app_first', apps=", ".join(apps_on_that_domain))
operation_logger.start()
ldap = _get_ldap_interface()