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'))