deluge: Allow to set a download directory

- add directory selection form to the app configuration page
- add debian-deluged user to the freedombox-share group
- storage: new validator parameter check-creatable
  (because deluged is able to create subdirectories)

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Veiko Aasa authored and James Valleroy committed 2020-01-25 18:27:11 -05:00
1 parent e217a4c87e
commit 8e698987de
8 files changed
+195 -17

No files matched your search

+8 -2
View File
@@ -60,14 +60,18 @@ def is_module_enabled(name):
class DirectoryValidator:
username = None
check_writable = False
check_creatable = False
add_user_to_share_group = False
service_to_restart = None
def __init__(self, username=None, check_writable=None):
def __init__(self, username=None, check_writable=None,
check_creatable=None):
if username is not None:
self.username = username
if check_writable is not None:
self.check_writable = check_writable
if check_creatable is not None:
self.check_creatable = check_creatable
def __call__(self, value):
"""Validate a directory."""
@@ -75,7 +79,9 @@ class DirectoryValidator:
raise ValidationError(_('Invalid directory name.'), 'invalid')
command = ['validate-directory', '--path', value]
if self.check_writable:
if self.check_creatable:
command.append('--check-creatable')
elif self.check_writable:
command.append('--check-writable')
if self.username:
+17 -1
View File
@@ -247,11 +247,14 @@ class TestActions:
subprocess.run(command, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, check=True)
def assert_validate_directory(self, path, error, check_writable=False):
def assert_validate_directory(self, path, error, check_writable=False,
check_creatable=False):
"""Perform directory validation checks."""
action_command = ['storage', 'validate-directory', '--path', path]
if check_writable:
action_command += ['--check-writable']
if check_creatable:
action_command += ['--check-creatable']
proc = self.call_action(action_command, stderr=subprocess.PIPE,
stdout=subprocess.PIPE)
output = proc.stdout.decode()
@@ -291,3 +294,16 @@ class TestActions:
"""Test that directory writable validation returns expected output."""
self.assert_validate_directory(directory['path'], directory['error'],
check_writable=True)
@pytest.mark.usefixtures('needs_not_root')
@pytest.mark.parametrize('directory', [{
'path': '/var/lib/plinth_storage_test_not_exists',
'error': '4'
}, {
'path': '/tmp/plint_storage_test_not_exists',
'error': ''
}])
def test_validate_directory_creatable(self, directory):
"""Test that directory creatable validation returns expected output."""
self.assert_validate_directory(directory['path'], directory['error'],
check_creatable=True)