Merge pull request #769 from YunoHost/stop_on_failed_app_upgrade

Stop on failed app upgrade
This commit is contained in:
Alexandre Aubin 2019-09-17 20:50:12 +02:00 committed by GitHub
commit 8fc005cec5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 10 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 app '{failed_app}' failed to upgrade, and as a consequence the following apps upgrades have been cancelled: {apps}",
"app_upgrade_stopped": "The upgrade of all applications has been stopped to prevent possible damage 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

@ -590,9 +590,6 @@ def app_upgrade(app=[], url=None, file=None):
from yunohost.hook import hook_add, hook_remove, hook_exec, hook_callback
from yunohost.permission import permission_sync_to_user
# Retrieve interface
is_api = msettings.get('interface') == 'api'
try:
app_list()
except YunohostError:
@ -621,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)
@ -675,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 if there are remaining apps
if apps[number + 1:]:
logger.error(m18n.n('app_upgrade_stopped'))
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
@ -712,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'))