Skip to content
Snippets Groups Projects
Commit ff9f295f authored by David Bauer's avatar David Bauer
Browse files

gluon-core: util: check if file exists prior to reading


The file_contains_line helper function was not testing whether a file
exists or not prior attempting to read from it.

Add this check to circumvent errors on the private WiFi config in
case the hwflags file is missing.

Reported-by: default avatarTom Herbers <freifunk@tomherbers.de>
Tested-by: default avatarTom Herbers <freifunk@tomherbers.de>
Signed-off-by: default avatarDavid Bauer <mail@david-bauer.net>
parent 1b620c83
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ local posix_syslog = require 'posix.syslog'
local hash = require 'hash'
local sysconfig = require 'gluon.sysconfig'
local site = require 'gluon.site'
local unistd = require 'posix.unistd'
local M = {}
......@@ -37,6 +38,10 @@ function M.contains(table, value)
end
function M.file_contains_line(path, value)
if not unistd.access(path) then
return false
end
for line in io.lines(path) do
if line == value then
return true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment