mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Do not advertise upgrades for bad-quality apps
This commit is contained in:
parent
711b64f81e
commit
cb1d02243e
1 changed files with 16 additions and 6 deletions
|
@ -182,19 +182,29 @@ def _app_upgradable(app_infos):
|
|||
from packaging import version
|
||||
|
||||
# Determine upgradability
|
||||
# In case there is neither update_time nor install_time, we assume the app can/has to be upgraded
|
||||
|
||||
# Firstly use the version to know if an upgrade is available
|
||||
app_is_in_catalog = bool(app_infos.get("from_catalog"))
|
||||
app_in_catalog = app_infos.get("from_catalog")
|
||||
installed_version = version.parse(app_infos.get("version", "0~ynh0"))
|
||||
version_in_catalog = version.parse(app_infos.get("from_catalog", {}).get("manifest", {}).get("version", "0~ynh0"))
|
||||
|
||||
if app_is_in_catalog and '~ynh' in str(installed_version) and '~ynh' in str(version_in_catalog):
|
||||
if not app_in_catalog:
|
||||
return "url_required"
|
||||
|
||||
# Do not advertise upgrades for bad-quality apps
|
||||
if not app_in_catalog.get("level", -1) >= 5 or app_in_catalog.get("state") != "working":
|
||||
return "bad_quality"
|
||||
|
||||
# If the app uses the standard version scheme, use it to determine
|
||||
# upgradability
|
||||
if '~ynh' in str(installed_version) and '~ynh' in str(version_in_catalog):
|
||||
if installed_version < version_in_catalog:
|
||||
return "yes"
|
||||
else:
|
||||
return "no"
|
||||
|
||||
if not app_is_in_catalog:
|
||||
return "url_required"
|
||||
# Legacy stuff for app with old / non-standard version numbers...
|
||||
|
||||
# In case there is neither update_time nor install_time, we assume the app can/has to be upgraded
|
||||
if not app_infos["from_catalog"].get("lastUpdate") or not app_infos["from_catalog"].get("git"):
|
||||
return "url_required"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue