aboutsummaryrefslogtreecommitdiffstats
path: root/util/datamanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-10-22 23:12:26 +0100
committerMatthew Wild <mwild1@gmail.com>2008-10-22 23:12:26 +0100
commite92bd250d19de43dfe0584108d12577bbe1a1c2a (patch)
tree01823b0990afedda8cc7ca448f9f975cd6e9d936 /util/datamanager.lua
parentee7b432ab1d450a42fae24b37c79b7fbda7f4e6b (diff)
parentc3ca55e0195d03c3e0c23590c387c49068be7723 (diff)
downloadprosody-e92bd250d19de43dfe0584108d12577bbe1a1c2a.tar.gz
prosody-e92bd250d19de43dfe0584108d12577bbe1a1c2a.zip
Merge roster & presence from waqas
Diffstat (limited to 'util/datamanager.lua')
-rw-r--r--util/datamanager.lua15
1 files changed, 12 insertions, 3 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua
index 1deb6b3d..f4ae958c 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -68,16 +68,25 @@ end
function load(username, host, datastore)
local data, ret = loadfile(getpath(username, host, datastore));
- if not data then log("warn", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..username.."@"..host); return nil; end
+ if not data then
+ log("warn", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or nil).."@"..(host or nil));
+ return nil;
+ end
setfenv(data, {});
local success, ret = pcall(data);
- if not success then log("error", "Unable to load "..datastore.." storage ('"..ret.."') for user: "..username.."@"..host); return nil; end
+ if not success then
+ log("error", "Unable to load "..datastore.." storage ('"..ret.."') for user: "..(username or nil).."@"..(host or nil));
+ return nil;
+ end
return ret;
end
function store(username, host, datastore, data)
local f, msg = io_open(getpath(username, host, datastore), "w+");
- if not f then log("error", "Unable to write to "..datastore.." storage ('"..msg.."') for user: "..username.."@"..host); return nil; end
+ if not f then
+ log("error", "Unable to write to "..datastore.." storage ('"..msg.."') for user: "..(username or nil).."@"..(host or nil));
+ return nil;
+ end
f:write("return ");
simplesave(f, data);
f:close();