From 050750b7c986f064e4a8c1f54a9c23911f3dc9f7 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 17 Aug 2019 17:43:38 +0200 Subject: [PATCH] Propagate the changes on other parts of the code relying on the appslist system --- src/yunohost/app.py | 22 ++-------------------- src/yunohost/tools.py | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index b2e276fe3..aa2163cdf 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -86,28 +86,10 @@ def app_list(filter=None, raw=False, installed=False, with_backup=False): """ installed = with_backup or installed - app_dict = {} list_dict = {} if raw else [] - appslists = _read_appslist_list() - - for appslist in appslists.keys(): - - json_path = "%s/%s.json" % (REPO_PATH, appslist) - - # If we don't have the json yet, try to fetch it - if not os.path.exists(json_path): - app_fetchlist(name=appslist) - - # If it now exist - if os.path.exists(json_path): - appslist_content = read_json(json_path) - for app, info in appslist_content.items(): - if app not in app_dict: - info['repository'] = appslist - app_dict[app] = info - else: - logger.warning("Uh there's no data for applist '%s' ... (That should be just a temporary issue?)" % appslist) + # Get app list from applist cache + app_dict = _load_appslist() # Get app list from the app settings directory for app in os.listdir(APPS_SETTING_PATH): diff --git a/src/yunohost/tools.py b/src/yunohost/tools.py index c63f1ed33..d9b50280c 100644 --- a/src/yunohost/tools.py +++ b/src/yunohost/tools.py @@ -38,7 +38,7 @@ from moulinette import msignals, m18n from moulinette.utils.log import getActionLogger from moulinette.utils.process import check_output, call_async_output from moulinette.utils.filesystem import read_json, write_to_json -from yunohost.app import app_fetchlist, app_info, app_upgrade, app_ssowatconf, app_list, _install_appslist_fetch_cron +from yunohost.app import _update_appslist, app_info, app_upgrade, app_ssowatconf, app_list from yunohost.domain import domain_add, domain_list, _get_maindomain, _set_maindomain from yunohost.dyndns import _dyndns_available, _dyndns_provides from yunohost.firewall import firewall_upnp @@ -411,15 +411,17 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False, # Enable UPnP silently and reload firewall firewall_upnp('enable', no_refresh=True) - # Setup the default apps list with cron job + # Initialize the appslist system + _initialize_appslist_system() + + # Try to update the appslist ... + # we don't fail miserably if this fails, + # because that could be for example an offline installation... try: - app_fetchlist(name="yunohost", - url="https://app.yunohost.org/apps.json") + _update_appslist() except Exception as e: logger.warning(str(e)) - _install_appslist_fetch_cron() - # Init migrations (skip them, no need to run them on a fresh system) _skip_all_migrations() @@ -465,6 +467,7 @@ def tools_update(apps=False, system=False): Keyword arguments: system -- Fetch available system packages upgrades (equivalent to apt update) apps -- Fetch the application list to check which apps can be upgraded + appslist -- Just update the application list cache """ # If neither --apps nor --system specified, do both @@ -510,11 +513,10 @@ def tools_update(apps=False, system=False): upgradable_apps = [] if apps: - logger.info(m18n.n('updating_app_lists')) try: - app_fetchlist() + _update_appslist() except YunohostError as e: - logger.error(m18n.n('tools_update_failed_to_app_fetchlist'), error=e) + logger.error(str(e)) upgradable_apps = list(_list_upgradable_apps())