From e208bdbbcafc7f6e1268bd153efb38567adab124 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 14 Feb 2024 15:47:41 -0800 Subject: [PATCH] setup: Ensure that force upgrade won't run when app is not installed - This keep the initial setup of the app simple and efficient. Setup will be less prone to any issues in force upgrade code. There are also fewer chances for immediate regressions. Tests: - Tested as part of the patch series. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/setup.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/plinth/setup.py b/plinth/setup.py index 97cbfd89e..4c3581786 100644 --- a/plinth/setup.py +++ b/plinth/setup.py @@ -56,14 +56,15 @@ def _run_setup_on_app(app, current_version): exception_to_update = None message = None try: - force_upgrader = ForceUpgrader.get_instance() - - # Check if this app needs force_upgrade. If it is needed, but not yet - # supported for the new version of the package, then an exception will - # be raised, so that we do not run setup. - force_upgrader.attempt_upgrade_for_app(app.app_id) - current_version = app.get_setup_version() + + if current_version != 0: + # Check if this app needs force_upgrade. If it is needed, but not + # yet supported for the new version of the package, then an + # exception will be raised, so that we do not run setup. + force_upgrader = ForceUpgrader.get_instance() + force_upgrader.attempt_upgrade_for_app(app.app_id) + app.setup(old_version=current_version) app.set_setup_version(app.info.version) post_setup.send_robust(sender=app.__class__, module_name=app.app_id)