Software /
code /
prosody
Changeset
3844:9cdc19ed3034
util.datamanager: When failing to load a list file, and the file exists, log an error, and return nil, error.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Fri, 10 Dec 2010 00:21:09 +0500 |
parents | 3843:997f699323f6 |
children | 3845:4860853fc97b |
files | util/datamanager.lua |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/util/datamanager.lua Fri Dec 10 00:07:28 2010 +0500 +++ b/util/datamanager.lua Fri Dec 10 00:21:09 2010 +0500 @@ -204,8 +204,15 @@ function list_load(username, host, datastore) local data, ret = loadfile(getpath(username, host, datastore, "list")); if not data then - log("debug", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil")); - return nil; + local mode = lfs.attributes(getpath(username, host, datastore, "list"), "mode"); + if not mode then + log("debug", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil")); + return nil; + else -- file exists, but can't be read + -- TODO more detailed error checking and logging? + log("error", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil")); + return nil, "Error reading storage"; + end end local items = {}; setfenv(data, {item = function(i) t_insert(items, i); end});