storage: Directory selection form improvements

- Action script:
  - must not be root when validating directory
  - return only first validation error
- Directory selection form, transmission, deluge:
  show the download path as it is in the configuration,
  the path is resolved only on form submit.
- Tests: add relative path checks, refactor parametrize code

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-03-02 20:51:41 -05:00
1 parent 03b4accefb
commit e7afa69155
7 files changed
+26 -46

No files matched your search

+6 -2
View File
@@ -333,6 +333,9 @@ def subcommand_usage_info(_):
def subcommand_validate_directory(arguments):
"""Validate a directory"""
if os.geteuid() == 0:
raise RuntimeError('You must not be root to run this command')
directory = arguments.path
def part_exists(path):
@@ -349,14 +352,15 @@ def subcommand_validate_directory(arguments):
if not os.path.exists(directory):
# doesn't exist
print('ValidationError: 1')
return
if not os.path.isdir(directory):
# is not a directory
print('ValidationError: 2')
if not os.access(directory, os.R_OK):
elif not os.access(directory, os.R_OK):
# is not readable
print('ValidationError: 3')
if arguments.check_writable or arguments.check_creatable:
elif arguments.check_writable or arguments.check_creatable:
if not os.access(directory, os.W_OK):
# is not writable
print('ValidationError: 4')