[fix] app conflicting with itself during change_url

This commit is contained in:
Alexandre Aubin 2019-01-24 17:02:42 +01:00
parent 270bfb54cd
commit 02e6c1241f
2 changed files with 5 additions and 2 deletions

View file

@ -465,7 +465,7 @@ def app_change_url(operation_logger, auth, app, domain, path):
raise YunohostError("app_change_url_identical_domains", domain=domain, path=path)
# Check the url is available
conflicts = _get_conflicting_apps(auth, domain, path)
conflicts = _get_conflicting_apps(auth, domain, path, ignore_app=app)
if conflicts:
apps = []
for path, app_id, app_label in conflicts:

View file

@ -226,13 +226,14 @@ def domain_cert_renew(auth, domain_list, force=False, no_checks=False, email=Fal
return yunohost.certificate.certificate_renew(auth, domain_list, force, no_checks, email, staging)
def _get_conflicting_apps(auth, domain, path):
def _get_conflicting_apps(auth, domain, path, ignore_app=None):
"""
Return a list of all conflicting apps with a domain/path (it can be empty)
Keyword argument:
domain -- The domain for the web path (e.g. your.domain.tld)
path -- The path to check (e.g. /coffee)
ignore_app -- An optional app id to ignore (c.f. the change_url usecase)
"""
domain, path = _normalize_domain_path(domain, path)
@ -253,6 +254,8 @@ def _get_conflicting_apps(auth, domain, path):
if domain in apps_map:
# Loop through apps
for p, a in apps_map[domain].items():
if a["id"] == ignore_app:
continue
if path == p:
conflicts.append((p, a["id"], a["label"]))
# We also don't want conflicts with other apps starting with