mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Properly handle the sanity checks right after upgrades (in combination with managing the regular error code...). This is similar to what's done for app_install
This commit is contained in:
parent
08ecace5ec
commit
c530325e29
1 changed files with 66 additions and 41 deletions
|
@ -666,10 +666,34 @@ def app_upgrade(app=[], url=None, file=None):
|
|||
|
||||
# Execute App upgrade script
|
||||
os.system('chown -hR admin: %s' % INSTALL_TMP)
|
||||
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)
|
||||
operation_logger.error(msg)
|
||||
|
||||
|
||||
try:
|
||||
upgrade_retcode = hook_exec(extracted_app_folder + '/scripts/upgrade',
|
||||
args=args_list, env=env_dict)[0]
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
upgrade_retcode = -1
|
||||
except Exception:
|
||||
import traceback
|
||||
logger.exception(m18n.n('unexpected_error', error=u"\n" + traceback.format_exc()))
|
||||
finally:
|
||||
|
||||
# Did the script succeed ?
|
||||
if upgrade_retcode != 0:
|
||||
error_msg = m18n.n('app_upgrade_failed', app=app_instance_name)
|
||||
operation_logger.error(error_msg)
|
||||
|
||||
# Did it broke the system ?
|
||||
try:
|
||||
broke_the_system = False
|
||||
_assert_system_is_sane_for_app(manifest, "post")
|
||||
except Exception as e:
|
||||
broke_the_system = True
|
||||
error_msg = operation_logger.error(str(e))
|
||||
|
||||
# If upgrade failed or broke the system,
|
||||
# raise an error and interrupt all other pending upgrades
|
||||
if upgrade_retcode != 0 or broke_the_system:
|
||||
|
||||
# display this if there are remaining apps
|
||||
if apps[number + 1:]:
|
||||
|
@ -681,7 +705,9 @@ def app_upgrade(app=[], url=None, file=None):
|
|||
failed_app=app_instance_name,
|
||||
apps=', '.join(not_upgraded_apps))
|
||||
else:
|
||||
raise YunohostError(msg)
|
||||
raise YunohostError(error_msg, raw_msg=True)
|
||||
|
||||
# Otherwise we're good and keep going !
|
||||
else:
|
||||
now = int(time.time())
|
||||
# TODO: Move install_time away from app_setting
|
||||
|
@ -713,7 +739,6 @@ def app_upgrade(app=[], url=None, file=None):
|
|||
# So much win
|
||||
logger.success(m18n.n('app_upgraded', app=app_instance_name))
|
||||
|
||||
_assert_system_is_sane_for_app(manifest, "post")
|
||||
hook_callback('post_app_upgrade', args=args_list, env=env_dict)
|
||||
operation_logger.success()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue