Commit efc61cae authored by Ted Trask's avatar Ted Trask

Modified fs.lua to survive nil parameters. Added create_directory and used...

Modified fs.lua to survive nil parameters.  Added create_directory and used within create_file and write_file.  Reviewed each read_file call to make sure handles nil return value.

git-svn-id: svn://svn.alpinelinux.org/acf/dnscache/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed
parent efcb3e4c
......@@ -68,7 +68,7 @@ function getstatus()
end
function getconfig()
local conf = format.parse_ini_file(fs.read_file(configfile), "") or {}
local conf = format.parse_ini_file(fs.read_file(configfile) or "", "") or {}
local output = {}
output.IPSEND = cfe({ value = conf.IPSEND or "", label="IP address for requests",
descr="Use 0.0.0.0 for default address" })
......@@ -83,7 +83,7 @@ function setconfig(config)
local success, config = validateconfig(config)
if success then
local file = fs.read_file(configfile)
local file = fs.read_file(configfile) or ""
file = format.update_ini_file(file,"","IPSEND",config.value.IPSEND.value)
file = format.update_ini_file(file,"","CACHESIZE",config.value.CACHESIZE.value)
file = format.update_ini_file(file,"","IP",config.value.IP.value)
......@@ -202,7 +202,7 @@ function getDomain(getdomainname)
end
end
if not domain.errtxt then
local content = fs.read_file(baseurl.."servers/"..getdomainname)
local content = fs.read_file(baseurl.."servers/"..getdomainname) or ""
for name in string.gmatch(content.."\n", "([^\n]+)\n") do
table.insert(iplist.value, name)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment