Skip to content
Snippets Groups Projects
Unverified Commit 97f6710d authored by Martin Weinelt's avatar Martin Weinelt Committed by GitHub
Browse files

Merge pull request #2259 from blocktrron/bugfix-util-file-contains-line-exists

gluon-core: util: check if file exists prior to reading
parents 737a239c ff9f295f
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ local posix_syslog = require 'posix.syslog' ...@@ -4,6 +4,7 @@ local posix_syslog = require 'posix.syslog'
local hash = require 'hash' local hash = require 'hash'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local site = require 'gluon.site' local site = require 'gluon.site'
local unistd = require 'posix.unistd'
local M = {} local M = {}
...@@ -37,6 +38,10 @@ function M.contains(table, value) ...@@ -37,6 +38,10 @@ function M.contains(table, value)
end end
function M.file_contains_line(path, value) function M.file_contains_line(path, value)
if not unistd.access(path) then
return false
end
for line in io.lines(path) do for line in io.lines(path) do
if line == value then if line == value then
return true 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