util.stanza: Iterate on childtags instead of all childs.
[prosody.git] / util / datamanager.lua
index 57cd2594e954d81f9c9cc56310eb6434183a8caa..fbdfb581b66ef9208d37002c4e1b24125313f379 100644 (file)
@@ -204,15 +204,22 @@ 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});
        local success, ret = pcall(data);
        if not success then
                log("error", "Unable to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
-               return nil;
+               return nil, "Error reading storage";
        end
        return items;
 end