From fc496f1fd16145dfb463a306808bf128d6a755ab Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Fri, 10 Dec 2010 00:21:09 +0500 Subject: util.datamanager: When failing to load a list file, and the file exists, log an error, and return nil, error. --- util/datamanager.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'util/datamanager.lua') diff --git a/util/datamanager.lua b/util/datamanager.lua index 57cd2594..dfb74a63 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -204,8 +204,15 @@ end 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}); -- cgit v1.2.3