Check whether the file is readable

Since the validation fails with "or isn't readable", we should actually
check whether we can read the file. This way, when configuring TLS for
example, you get early feedback if the cert files are not readable.
This commit is contained in:
Michal Kuratczyk 2021-01-23 18:52:10 +01:00 committed by Michael Klishin
parent 589352c31a
commit ecd2d738c0
No known key found for this signature in database
GPG Key ID: E80EDCFA0CDB21EE
1 changed files with 4 additions and 2 deletions

View File

@ -1773,8 +1773,10 @@ end}.
{validator, "file_accessible", "file doesn't exist or isn't readable",
fun(File) ->
ReadFile = file:read_file_info(File),
element(1, ReadFile) == ok
case file:read_file_info(File) of
{ok, FileInfo} -> (element(4, FileInfo) == read) or (element(4, FileInfo) == read_write);
_ -> false
end
end}.
{validator, "is_ip", "string is a valid IP address",