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 | 6e604e9c75b1ba9698242ef0700eb14c2bc3b137 (patch) | |
| tree | 1a180b7ee10d08c4dc45912468bdbb92c12102c9 | |
| parent | 91e1593b3b5c32b4246a44b951e0aa6ad032e8db (diff) | |
| download | acf-fetchmail-6e604e9c75b1ba9698242ef0700eb14c2bc3b137.tar.bz2 acf-fetchmail-6e604e9c75b1ba9698242ef0700eb14c2bc3b137.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/fetchmail/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed
| -rw-r--r-- | fetchmail-model.lua | 12 | 
1 files changed, 6 insertions, 6 deletions
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 = {}  | 
