util.datamanager: When failing to load a list file, and the file exists, log an error...
authorWaqas Hussain <waqas20@gmail.com>
Thu, 9 Dec 2010 19:21:09 +0000 (00:21 +0500)
committerWaqas Hussain <waqas20@gmail.com>
Thu, 9 Dec 2010 19:21:09 +0000 (00:21 +0500)
util/datamanager.lua

index 57cd2594e954d81f9c9cc56310eb6434183a8caa..dfb74a631df86fdbe58f99578233c83f9b8b707e 100644 (file)
@@ -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});