From c34de0b792177676939c97a9d66f12e95bec3d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Fri, 24 Apr 2020 14:26:31 +0200 Subject: [PATCH] Improve version management in catalog --- src/yunohost/app.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 74a626597..5f0084f08 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -162,9 +162,13 @@ def _app_upgradable(app_infos): # 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 - if app_infos["manifest"].get('integration', {}).get("upgrade_only_if_version_changes", None) is True and \ - '~ynh' in app_infos["version"] and app_infos["from_catalog"]["manifest"].get("version", None): - if version.parse(app_infos["version"]) < version.parse(app_infos["from_catalog"]["manifest"].get("version", "-")): + app_is_in_catalog = bool(app_infos.get("from_catalog")) + upgrade_only_if_version_changes = app_infos["manifest"].get('integration', {}).get("upgrade_only_if_version_changes", None) is True + installed_version = version.parse(app_infos["version"]) + version_in_catalog = version.parse(app_infos.get("from_catalog", {}).get("manifest", {}).get("version", "0~ynh0")) + + if app_is_in_catalog and '~ynh' in app_infos["version"]: + if upgrade_only_if_version_changes and installed_version < version_in_catalog: return "yes" else: return "no"