From 54bebd7269558b4b1dc08ebdc91af3e652987d3b Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sat, 13 Dec 2025 12:33:24 +0530 Subject: [PATCH] transmission: Deal with changes in latest forky package Fixes: #2555 - '-' in configuration keys changed to '_'. Write both old and new keys to the configuration file so that same code works for both versions of transmission. Extra keys are ignored and removed from the configuration by the transmission daemon. - When reading the configuration for download directory account for both old and new keys. - Update functional tests for change in ID for delete torrent button. Tests: - Run functional tests on trixie and forky VM. - On trixie and forky VM, after the app is installed, the configuration values are set as expected in the configuration file. Transmission does not show its own authentication dialog. FreedomBox SSO works as expected. - On trixie and forky, updating the download dir in FreedomBox app changes the values in the web UI. - On forky, install transmission using old code and sources.list updated to trixie. Change the download directory. Stop service. Then update the sources.list to forky, apply patches and start service. Run unattended-upgrades. Notice that the earlier set download directory persists. Two configuration values for rpc also are as expected. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/transmission/__init__.py | 26 +++++++++++++++---- .../transmission/tests/test_functional.py | 10 ++++--- plinth/modules/transmission/views.py | 6 ++--- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/plinth/modules/transmission/__init__.py b/plinth/modules/transmission/__init__.py index 92ef05598..5c31c6ed7 100644 --- a/plinth/modules/transmission/__init__.py +++ b/plinth/modules/transmission/__init__.py @@ -91,7 +91,8 @@ class TransmissionApp(app_module.App): allowed_groups=list(groups)) self.add(shortcut) - packages = Packages('packages-transmission', ['transmission-daemon']) + packages = Packages('packages-transmission', ['transmission-daemon'], + rerun_setup_on_upgrade=True) self.add(packages) dropin_configs = DropinConfigs('dropin-configs-transmission', [ @@ -135,15 +136,30 @@ class TransmissionApp(app_module.App): """Install and configure the app.""" super().setup(old_version) - if old_version and old_version <= 3 and self.is_enabled(): - self.get_component('firewall-transmission').enable() - new_configuration = { 'rpc-whitelist-enabled': False, - 'rpc-authentication-required': False + 'rpc_whitelist_enabled': False, + 'rpc-authentication-required': False, + 'rpc_authentication_required': False, } + + if old_version: + download_dir = get_download_dir() + new_configuration['download-dir'] = download_dir + new_configuration['download_dir'] = download_dir + privileged.merge_configuration(new_configuration) add_user_to_share_group(SYSTEM_USER, TransmissionApp.DAEMON) if not old_version: self.enable() + + +def get_download_dir() -> str: + """Return the configured download directory.""" + configuration = privileged.get_configuration() + old = configuration.get('download-dir') # Trixie and older + if old: + return old + + return configuration.get('download_dir') # Forky and newer diff --git a/plinth/modules/transmission/tests/test_functional.py b/plinth/modules/transmission/tests/test_functional.py index 2b0981431..33773f493 100644 --- a/plinth/modules/transmission/tests/test_functional.py +++ b/plinth/modules/transmission/tests/test_functional.py @@ -6,9 +6,10 @@ Functional, browser based tests for transmission app. import os import pytest -from plinth.tests import functional from splinter.exceptions import ElementDoesNotExist +from plinth.tests import functional + pytestmark = [pytest.mark.apps, pytest.mark.transmission, pytest.mark.sso] @@ -57,9 +58,10 @@ def _remove_all_torrents(browser): break torrents.first.click() - functional.eventually(browser.is_element_not_present_by_css, - args=['#toolbar-remove.disabled']) - browser.find_by_id('toolbar-remove').click() + functional.eventually( + browser.is_element_not_present_by_css, + args=['#toolbar-remove.disabled,#toolbar-delete.disabled']) + browser.find_by_css('#toolbar-remove,#toolbar-delete').first.click() functional.eventually( browser.is_element_not_present_by_css, args=['#dialog-container[style="display: none;"]']) diff --git a/plinth/modules/transmission/views.py b/plinth/modules/transmission/views.py index eab746dfd..8f0561c53 100644 --- a/plinth/modules/transmission/views.py +++ b/plinth/modules/transmission/views.py @@ -11,7 +11,7 @@ from django.utils.translation import gettext as _ from plinth import views -from . import privileged +from . import get_download_dir, privileged from .forms import TransmissionForm logger = logging.getLogger(__name__) @@ -25,8 +25,7 @@ class TransmissionAppView(views.AppView): def get_initial(self): """Get the current settings from Transmission server.""" status = super().get_initial() - configuration = privileged.get_configuration() - status['storage_path'] = configuration['download-dir'] + status['storage_path'] = get_download_dir() status['hostname'] = socket.gethostname() return status @@ -38,6 +37,7 @@ class TransmissionAppView(views.AppView): if old_status['storage_path'] != new_status['storage_path']: new_configuration = { 'download-dir': new_status['storage_path'], + 'download_dir': new_status['storage_path'], } privileged.merge_configuration(new_configuration) messages.success(self.request, _('Configuration updated'))