diff options
author | Ted Trask <ttrask01@yahoo.com> | 2009-01-13 16:01:06 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2009-01-13 16:01:06 +0000 |
commit | efc61cae908bd93c2828dd14cb98c23b1385a67a (patch) | |
tree | 676f7a9757a9aa4af8da0b14a63a5db31a2a40e9 | |
parent | efcb3e4c36a9846105703fbd8978a85d27bcc6f7 (diff) | |
download | acf-dnscache-efc61cae908bd93c2828dd14cb98c23b1385a67a.tar.bz2 acf-dnscache-efc61cae908bd93c2828dd14cb98c23b1385a67a.tar.xz |
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
-rw-r--r-- | dnscache-model.lua | 6 |
1 files 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 |