From 5af2d44f83ca2ab3aee6cca2ce46fd4708e150b9 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 2 Jun 2023 15:31:03 -0700 Subject: [PATCH] apache: Fix failure during app update - During application update, if the last_updated_version is not provided for the WebServer component, app's update to next version fails. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/apache/components.py | 2 +- plinth/modules/apache/tests/test_components.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/plinth/modules/apache/components.py b/plinth/modules/apache/components.py index d993d3235..77fa70239 100644 --- a/plinth/modules/apache/components.py +++ b/plinth/modules/apache/components.py @@ -44,7 +44,7 @@ class Webserver(app.LeaderComponent): self.kind = kind self.urls = urls or [] self.expect_redirects = expect_redirects - self.last_updated_version = last_updated_version + self.last_updated_version = last_updated_version or 0 def is_enabled(self): """Return whether the Apache configuration is enabled.""" diff --git a/plinth/modules/apache/tests/test_components.py b/plinth/modules/apache/tests/test_components.py index 35a120c33..491452e61 100644 --- a/plinth/modules/apache/tests/test_components.py +++ b/plinth/modules/apache/tests/test_components.py @@ -109,6 +109,14 @@ def test_webserver_setup(service_reload, service_restart): return self.enabled app1 = AppTest() + + # Don't fail when last_updated_version is not provided. + webserver1 = Webserver('test-webserver1', 'test-config') + assert webserver1.last_updated_version == 0 + webserver1.setup(old_version=10) + service_reload.assert_not_called() + service_restart.assert_not_called() + webserver1 = Webserver('test-webserver1', 'test-config', last_updated_version=5) for version in (0, 5, 6):