From 6e604e9c75b1ba9698242ef0700eb14c2bc3b137 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/fetchmail/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed --- fetchmail-model.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'fetchmail-model.lua') diff --git a/fetchmail-model.lua b/fetchmail-model.lua index b92e1e7..16b0cad 100644 --- a/fetchmail-model.lua +++ b/fetchmail-model.lua @@ -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 = {} -- cgit v1.2.3