[mod] stop apps upgrade if one upgrade fail

This commit is contained in:
Laurent Peuch 2019-08-07 02:28:37 +02:00 committed by Alexandre Aubin
parent 930b8378a1
commit 3130bb59ac
2 changed files with 15 additions and 7 deletions

View file

@ -28,7 +28,8 @@
"app_location_unavailable": "This url is not available or conflicts with the already installed app(s):\n{apps:s}",
"app_manifest_invalid": "Invalid app manifest: {error}",
"app_no_upgrade": "No apps to upgrade",
"app_not_upgraded": "The following apps were not upgraded: {apps}",
"app_not_upgraded": "The following apps were not upgraded because a the app '{app}' failed to upgrade: {apps}",
"app_upgrade_stoped": "The upgrade of alls applications has been stopped to prevent possible dommages because the previous application failed to upgrade",
"app_not_correctly_installed": "{app:s} seems to be incorrectly installed",
"app_not_installed": "The application '{app:s}' is not installed. Here is the list of all installed apps: {all_apps}",
"app_not_properly_removed": "{app:s} has not been properly removed",

View file

@ -618,7 +618,7 @@ def app_upgrade(app=[], url=None, file=None):
if len(apps) > 1:
logger.info(m18n.n("app_upgrade_several_apps", apps=", ".join(apps)))
for app_instance_name in apps:
for number, app_instance_name in enumerate(apps):
logger.info(m18n.n('app_upgrade_app_name', app=app_instance_name))
app_dict = app_info(app_instance_name, raw=True)
@ -672,9 +672,19 @@ def app_upgrade(app=[], url=None, file=None):
if hook_exec(extracted_app_folder + '/scripts/upgrade',
args=args_list, env=env_dict)[0] != 0:
msg = m18n.n('app_upgrade_failed', app=app_instance_name)
not_upgraded_apps.append(app_instance_name)
logger.error(msg)
operation_logger.error(msg)
# display this is there are remaining apps
if apps[number + 1:]:
logger.error(m18n.n('app_upgrade_stoped'))
not_upgraded_apps = apps[number:]
# we don't want to continue upgrading apps here in case that breaks
# everything
raise YunohostError('app_not_upgraded',
failed_app=app_instance_name,
apps=', '.join(not_upgraded_apps))
else:
raise YunohostError(msg)
else:
now = int(time.time())
# TODO: Move install_time away from app_setting
@ -709,9 +719,6 @@ def app_upgrade(app=[], url=None, file=None):
hook_callback('post_app_upgrade', args=args_list, env=env_dict)
operation_logger.success()
if not_upgraded_apps:
raise YunohostError('app_not_upgraded', apps=', '.join(not_upgraded_apps))
permission_sync_to_user()
logger.success(m18n.n('upgrade_complete'))