From e9056afe003c5102761a81527e9070242e681198 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sat, 22 Jul 2023 13:05:54 -0700 Subject: [PATCH] tor: Minor refactor to remove code the check for need to restart - Any change to the remaining form fields now certainly requires restart of the Tor daemon. Tests: - When no changes are done to the form, tor daemon is not restarted. - When changes are done to the form, tor daemon is restarted. But only when app is enabled. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/tor/views.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/plinth/modules/tor/views.py b/plinth/modules/tor/views.py index 3d348bb78..1e6004093 100644 --- a/plinth/modules/tor/views.py +++ b/plinth/modules/tor/views.py @@ -79,38 +79,31 @@ def _apply_changes(old_status, new_status): def __apply_changes(old_status, new_status): """Apply the changes.""" - needs_restart = False arguments = {} - app = app_module.App.get('tor') is_enabled = app.is_enabled() if old_status['relay_enabled'] != new_status['relay_enabled']: arguments['relay'] = new_status['relay_enabled'] - needs_restart = True if old_status['bridge_relay_enabled'] != \ new_status['bridge_relay_enabled']: arguments['bridge_relay'] = new_status['bridge_relay_enabled'] - needs_restart = True if old_status['hs_enabled'] != new_status['hs_enabled']: arguments['hidden_service'] = new_status['hs_enabled'] - needs_restart = True if old_status['use_upstream_bridges'] != \ new_status['use_upstream_bridges']: arguments['use_upstream_bridges'] = new_status['use_upstream_bridges'] - needs_restart = True if old_status['upstream_bridges'] != new_status['upstream_bridges']: arguments['upstream_bridges'] = new_status['upstream_bridges'] - needs_restart = True if arguments: privileged.configure(**arguments) - if needs_restart and is_enabled: - privileged.restart() - status = tor_utils.get_status() - tor.update_hidden_service_domain(status) + if is_enabled: + privileged.restart() + status = tor_utils.get_status() + tor.update_hidden_service_domain(status)