mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] display which app conflict on domain/path not available
This commit is contained in:
parent
05e1be86c6
commit
66f9244961
3 changed files with 27 additions and 11 deletions
|
@ -22,7 +22,7 @@
|
||||||
"app_location_already_used": "The app '{app}' is already installed on that location ({path})",
|
"app_location_already_used": "The app '{app}' is already installed on that location ({path})",
|
||||||
"app_make_default_location_already_used": "Can't make the app '{app}' the default on the domain {domain} is already used by the other app '{other_app}'",
|
"app_make_default_location_already_used": "Can't make the app '{app}' the default on the domain {domain} is already used by the other app '{other_app}'",
|
||||||
"app_location_install_failed": "Unable to install the app in this location because it conflit with the app '{other_app}' already installed on '{other_path}'",
|
"app_location_install_failed": "Unable to install the app in this location because it conflit with the app '{other_app}' already installed on '{other_path}'",
|
||||||
"app_location_unavailable": "This url is not available or conflicts with an already installed app",
|
"app_location_unavailable": "This url is not available or conflicts with the already installed app '{app_label:s}' ({app_id:s}) on '{domain:s}{path:s}'",
|
||||||
"app_manifest_invalid": "Invalid app manifest: {error}",
|
"app_manifest_invalid": "Invalid app manifest: {error}",
|
||||||
"app_no_upgrade": "No app to upgrade",
|
"app_no_upgrade": "No app to upgrade",
|
||||||
"app_not_correctly_installed": "{app:s} seems to be incorrectly installed",
|
"app_not_correctly_installed": "{app:s} seems to be incorrectly installed",
|
||||||
|
|
|
@ -1147,7 +1147,7 @@ def app_register_url(auth, app, domain, path):
|
||||||
|
|
||||||
# This line can't be moved on top of file, otherwise it creates an infinite
|
# This line can't be moved on top of file, otherwise it creates an infinite
|
||||||
# loop of import with tools.py...
|
# loop of import with tools.py...
|
||||||
from domain import domain_url_available, _normalize_domain_path
|
from domain import _get_conflicting_app, _normalize_domain_path
|
||||||
|
|
||||||
domain, path = _normalize_domain_path(domain, path)
|
domain, path = _normalize_domain_path(domain, path)
|
||||||
|
|
||||||
|
@ -1163,9 +1163,11 @@ def app_register_url(auth, app, domain, path):
|
||||||
m18n.n('app_already_installed_cant_change_url'))
|
m18n.n('app_already_installed_cant_change_url'))
|
||||||
|
|
||||||
# Check the url is available
|
# Check the url is available
|
||||||
if not domain_url_available(auth, domain, path):
|
path_and_app = _get_conflicting_app(auth, domain, path)
|
||||||
|
if not path_and_app:
|
||||||
|
path, app_id, app_label = path_and_app
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError(errno.EINVAL,
|
||||||
m18n.n('app_location_unavailable'))
|
m18n.n('app_location_unavailable', app_id=app_id, app_label=app_label, path=path, domain=domain))
|
||||||
|
|
||||||
app_setting(app, 'domain', value=domain)
|
app_setting(app, 'domain', value=domain)
|
||||||
app_setting(app, 'path', value=path)
|
app_setting(app, 'path', value=path)
|
||||||
|
@ -2050,7 +2052,7 @@ def _parse_action_args_in_yunohost_format(args, action_args, auth=None):
|
||||||
"""Parse arguments store in either manifest.json or actions.json
|
"""Parse arguments store in either manifest.json or actions.json
|
||||||
"""
|
"""
|
||||||
from yunohost.domain import (domain_list, _get_maindomain,
|
from yunohost.domain import (domain_list, _get_maindomain,
|
||||||
domain_url_available, _normalize_domain_path)
|
_get_conflicting_app, _normalize_domain_path)
|
||||||
from yunohost.user import user_info, user_list
|
from yunohost.user import user_info, user_list
|
||||||
|
|
||||||
args_dict = OrderedDict()
|
args_dict = OrderedDict()
|
||||||
|
@ -2178,9 +2180,11 @@ def _parse_action_args_in_yunohost_format(args, action_args, auth=None):
|
||||||
domain, path = _normalize_domain_path(domain, path)
|
domain, path = _normalize_domain_path(domain, path)
|
||||||
|
|
||||||
# Check the url is available
|
# Check the url is available
|
||||||
if not domain_url_available(auth, domain, path):
|
path_and_app = _get_conflicting_app(auth, domain, path)
|
||||||
|
if not path_and_app:
|
||||||
|
path, app_id, app_label = path_and_app
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError(errno.EINVAL,
|
||||||
m18n.n('app_location_unavailable'))
|
m18n.n('app_location_unavailable', app_id=app_id, app_label=app_label, path=path, domain=domain))
|
||||||
|
|
||||||
# (We save this normalized path so that the install script have a
|
# (We save this normalized path so that the install script have a
|
||||||
# standard path format to deal with no matter what the user inputted)
|
# standard path format to deal with no matter what the user inputted)
|
||||||
|
|
|
@ -219,7 +219,7 @@ 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)
|
return yunohost.certificate.certificate_renew(auth, domain_list, force, no_checks, email, staging)
|
||||||
|
|
||||||
|
|
||||||
def domain_url_available(auth, domain, path):
|
def _get_conflicting_app(auth, domain, path):
|
||||||
"""
|
"""
|
||||||
Check availability of a web path
|
Check availability of a web path
|
||||||
|
|
||||||
|
@ -246,13 +246,25 @@ def domain_url_available(auth, domain, path):
|
||||||
# Loop through apps
|
# Loop through apps
|
||||||
for p, a in apps_map[domain].items():
|
for p, a in apps_map[domain].items():
|
||||||
if path == p:
|
if path == p:
|
||||||
return False
|
return (p, a["id"], a["label"])
|
||||||
# We also don't want conflicts with other apps starting with
|
# We also don't want conflicts with other apps starting with
|
||||||
# same name
|
# same name
|
||||||
elif path.startswith(p) or p.startswith(path):
|
elif path.startswith(p) or p.startswith(path):
|
||||||
return False
|
return (p, a["id"], a["label"])
|
||||||
|
|
||||||
return True
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def domain_url_available(auth, domain, path):
|
||||||
|
"""
|
||||||
|
Check availability of a web path
|
||||||
|
|
||||||
|
Keyword argument:
|
||||||
|
domain -- The domain for the web path (e.g. your.domain.tld)
|
||||||
|
path -- The path to check (e.g. /coffee)
|
||||||
|
"""
|
||||||
|
|
||||||
|
return bool(_get_conflicting_app(auth, domain, path))
|
||||||
|
|
||||||
|
|
||||||
def _get_maindomain():
|
def _get_maindomain():
|
||||||
|
|
Loading…
Add table
Reference in a new issue