Sunil Mohan Adapa 54bebd7269
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 <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-12-15 20:12:20 -05:00

46 lines
1.3 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""
FreedomBox app for configuring Transmission Server.
"""
import logging
import socket
from django.contrib import messages
from django.utils.translation import gettext as _
from plinth import views
from . import get_download_dir, privileged
from .forms import TransmissionForm
logger = logging.getLogger(__name__)
class TransmissionAppView(views.AppView):
"""Serve configuration page."""
form_class = TransmissionForm
app_id = 'transmission'
def get_initial(self):
"""Get the current settings from Transmission server."""
status = super().get_initial()
status['storage_path'] = get_download_dir()
status['hostname'] = socket.gethostname()
return status
def form_valid(self, form):
"""Apply the changes submitted in the form."""
old_status = form.initial
new_status = form.cleaned_data
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'))
return super().form_valid(form)