From efc61cae908bd93c2828dd14cb98c23b1385a67a Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Tue, 13 Jan 2009 16:01:06 +0000 Subject: 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 --- dnscache-model.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dnscache-model.lua b/dnscache-model.lua index 46684cf..6ceac36 100644 --- a/dnscache-model.lua +++ b/dnscache-model.lua @@ -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 -- cgit v1.2.3