Commit 6e604e9c 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/fetchmail/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed
parent 91e1593b
......@@ -48,7 +48,7 @@ end
local function findentryline(entryname, method, remotemailbox, localdomain)
if entryname and entryname ~= "" then
config = config or parseconfigfile(fs.read_file(configfile))
config = config or parseconfigfile(fs.read_file(configfile) or "")
for i,entry in ipairs(config or {}) do
if (entry[1] == "server" or entry[1] == "poll" or entry[1] == "skip") and entry[2] == entryname then
local reverseentry = {}
......@@ -206,7 +206,7 @@ local function writeentryline(entrystruct, entryline)
entryline = insertentries
end
local file = fs.read_file(configfile)
local file = fs.read_file(configfile) or ""
local lines = {file}
if entryline and entryline.linenum then
......@@ -344,7 +344,7 @@ function getconfig()
local postmaster = cfe({ label="Postmaster", descr="If defined, undeliverable mail is sent to this account, otherwise it is discarded" })
local bounceerrors = cfe({ type="boolean", value=true, label="Bounce Errors", descr="Bounce errors back to the sender or send them to the postmaster" })
config = config or parseconfigfile(fs.read_file(configfile))
config = config or parseconfigfile(fs.read_file(configfile) or "")
for i,entry in ipairs(config or {}) do
if entry[2] == "postmaster" and entry[1] == "set" then
postmaster.value = entry[3] or ""
......@@ -353,7 +353,7 @@ function getconfig()
end
end
local confd = format.parse_ini_file(fs.read_file(confdfile), "", "polling_period")
local confd = format.parse_ini_file(fs.read_file(confdfile) or "", "", "polling_period")
if confd then
interval.value = string.sub(confd, 2, -2)
end
......@@ -365,7 +365,7 @@ function updateconfig(conf)
local success, conf = validateconfig(conf)
if success then
local file = fs.read_file(configfile)
local file = fs.read_file(configfile) or ""
local foundpostmaster, foundbounceerrors
local lines = {}
for line in string.gmatch(file, "([^\n]*\n?)") do
......@@ -401,7 +401,7 @@ end
function readentries()
local entries = cfe({ type="structure", value={}, label="List of Fetchmail entries" })
config = config or parseconfigfile(fs.read_file(configfile))
config = config or parseconfigfile(fs.read_file(configfile) or "")
for i,entry in ipairs(config or {}) do
if (entry[1] == "server" or entry[1] == "poll" or entry[1] == "skip") and entry[2] then
local reverseentry = {}
......
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