mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Clean app upgrade (#193)
* [mod] current_app_dict == new_app_dict so test is always false * [mod] simplify condition\n\nUntestedgit add -p * [mod] useless variable * [mod] rename variable * [mod] app_dict can't be None (exception is raised instead) * Adding debug message for upgrade * Using app_list to list installed apps * [mod] pep8 * [mod] please opi
This commit is contained in:
parent
d4feb879d4
commit
cc44512539
1 changed files with 11 additions and 12 deletions
|
@ -362,10 +362,12 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
|
|
||||||
# If no app is specified, upgrade all apps
|
# If no app is specified, upgrade all apps
|
||||||
if not app:
|
if not app:
|
||||||
if (not url and not file):
|
if not url and not file:
|
||||||
app = os.listdir(APPS_SETTING_PATH)
|
app = [app["id"] for app in app_list(installed=True)["apps"]]
|
||||||
elif not isinstance(app, list):
|
elif not isinstance(app, list):
|
||||||
app = [ app ]
|
app = [app]
|
||||||
|
|
||||||
|
logger.info("Upgrading apps %s", ", ".join(app))
|
||||||
|
|
||||||
for app_instance_name in app:
|
for app_instance_name in app:
|
||||||
installed = _is_installed(app_instance_name)
|
installed = _is_installed(app_instance_name)
|
||||||
|
@ -376,21 +378,18 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
if app_instance_name in upgraded_apps:
|
if app_instance_name in upgraded_apps:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
current_app_dict = app_info(app_instance_name, raw=True)
|
app_dict = app_info(app_instance_name, raw=True)
|
||||||
new_app_dict = app_info(app_instance_name, raw=True)
|
|
||||||
|
locale_update_time = app_dict['settings'].get('update_time', app_dict['settings']['install_time'])
|
||||||
|
|
||||||
if file:
|
if file:
|
||||||
manifest, extracted_app_folder = _extract_app_from_file(file)
|
manifest, extracted_app_folder = _extract_app_from_file(file)
|
||||||
elif url:
|
elif url:
|
||||||
manifest, extracted_app_folder = _fetch_app_from_git(url)
|
manifest, extracted_app_folder = _fetch_app_from_git(url)
|
||||||
elif new_app_dict is None or 'lastUpdate' not in new_app_dict or 'git' not in new_app_dict:
|
elif 'lastUpdate' not in app_dict or 'git' not in app_dict:
|
||||||
logger.warning(m18n.n('custom_app_url_required', app=app_instance_name))
|
logger.warning(m18n.n('custom_app_url_required', app=app_instance_name))
|
||||||
continue
|
continue
|
||||||
elif (new_app_dict['lastUpdate'] > current_app_dict['lastUpdate']) \
|
elif app_dict['lastUpdate'] > locale_update_time:
|
||||||
or ('update_time' not in current_app_dict['settings'] \
|
|
||||||
and (new_app_dict['lastUpdate'] > current_app_dict['settings']['install_time'])) \
|
|
||||||
or ('update_time' in current_app_dict['settings'] \
|
|
||||||
and (new_app_dict['lastUpdate'] > current_app_dict['settings']['update_time'])):
|
|
||||||
manifest, extracted_app_folder = _fetch_app_from_git(app_instance_name)
|
manifest, extracted_app_folder = _fetch_app_from_git(app_instance_name)
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
@ -399,7 +398,7 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
_check_manifest_requirements(manifest)
|
_check_manifest_requirements(manifest)
|
||||||
|
|
||||||
app_setting_path = APPS_SETTING_PATH +'/'+ app_instance_name
|
app_setting_path = APPS_SETTING_PATH +'/'+ app_instance_name
|
||||||
|
|
||||||
# Retrieve current app status
|
# Retrieve current app status
|
||||||
status = _get_app_status(app_instance_name)
|
status = _get_app_status(app_instance_name)
|
||||||
status['remote'] = manifest.get('remote', None)
|
status['remote'] = manifest.get('remote', None)
|
||||||
|
|
Loading…
Add table
Reference in a new issue