form:FileOption: fix cli file check

This commit is contained in:
axolotle 2023-11-29 14:09:36 +01:00
parent c5758bcd30
commit 6f9203c98c
2 changed files with 2 additions and 2 deletions

View file

@ -1298,7 +1298,7 @@ class TestFile(BaseTest):
def test_basic_attrs(self): def test_basic_attrs(self):
raw_option, option, value = self._test_basic_attrs() raw_option, option, value = self._test_basic_attrs()
accept = raw_option.get("accept", "") # accept default accept = raw_option.get("accept", None) # accept default
assert option.accept == accept assert option.accept == accept
def test_options_prompted_with_ask_help(self): def test_options_prompted_with_ask_help(self):

View file

@ -1317,7 +1317,7 @@ class FileOption(BaseInputOption):
if Moulinette.interface.type != "api": if Moulinette.interface.type != "api":
path = Path(value) path = Path(value)
if not (path.exists() or path.is_absolute() or path.is_file()): if not (path.exists() and path.is_absolute() and path.is_file()):
raise YunohostValidationError("File doesn't exists", raw_msg=True) raise YunohostValidationError("File doesn't exists", raw_msg=True)
content = path.read_bytes() content = path.read_bytes()
else: else: