From 413778d2bce74d51e4274cff4eecdb4713d60e19 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 15 May 2020 04:23:58 +0200 Subject: [PATCH] Check if app broke something important only if install succeeded (if install fails, this check only matters *after* we remove the app which is already done) --- src/yunohost/app.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index c8e37d787..a2ab5a25e 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -809,15 +809,15 @@ def app_install(operation_logger, app, label=None, args=None, no_remove_on_failu logger.error(m18n.n("app_install_failed", app=app_id, error=error)) failure_message_with_debug_instructions = operation_logger.error(error) finally: - # Whatever happened (install success or failure) we check if it broke the system - # and warn the user about it - try: - broke_the_system = False - _assert_system_is_sane_for_app(manifest, "post") - except Exception as e: - broke_the_system = True - logger.error(m18n.n("app_install_failed", app=app_id, error=str(e))) - failure_message_with_debug_instructions = operation_logger.error(str(e)) + # If success so far, validate that app didn't break important stuff + if not install_failed: + try: + broke_the_system = False + _assert_system_is_sane_for_app(manifest, "post") + except Exception as e: + broke_the_system = True + logger.error(m18n.n("app_install_failed", app=app_id, error=str(e))) + failure_message_with_debug_instructions = operation_logger.error(str(e)) # If the install failed or broke the system, we remove it if install_failed or broke_the_system: