aboutsummaryrefslogtreecommitdiffstats
path: root/core/storagemanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-12-17 13:50:33 +0000
committerMatthew Wild <mwild1@gmail.com>2010-12-17 13:50:33 +0000
commit8ee0fb71fcba10a54760d4a047a4a91e2ab97ad1 (patch)
tree08ff2f81be281c7d1f399e2e3ff5b74f1671b77b /core/storagemanager.lua
parentc1efda1ffd82e6988ab20b4be5f75ecf31fb551e (diff)
parent07e945631dc2abe7a2afe204919a72d25398c687 (diff)
downloadprosody-8ee0fb71fcba10a54760d4a047a4a91e2ab97ad1.tar.gz
prosody-8ee0fb71fcba10a54760d4a047a4a91e2ab97ad1.zip
Merge Tobias->trunk
Diffstat (limited to 'core/storagemanager.lua')
-rw-r--r--core/storagemanager.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/core/storagemanager.lua b/core/storagemanager.lua
index 0857baf4..e0c12190 100644
--- a/core/storagemanager.lua
+++ b/core/storagemanager.lua
@@ -11,6 +11,7 @@ local log = require "util.logger".init("storagemanager");
local olddm = {}; -- maintain old datamanager, for backwards compatibility
for k,v in pairs(datamanager) do olddm[k] = v; end
+local prosody = prosody;
module("storagemanager")
@@ -25,6 +26,7 @@ function default_driver_mt:set(user, data) return olddm.store(user, self.host, s
local stores_available = multitable.new();
function initialize_host(host)
+ local host_session = hosts[host];
host_session.events.add_handler("item-added/data-driver", function (event)
local item = event.item;
stores_available:set(host, item.name, item);
@@ -35,19 +37,19 @@ function initialize_host(host)
stores_available:set(host, item.name, nil);
end);
end
+prosody.events.add_handler("host-activated", initialize_host, 101);
local function load_driver(host, driver_name)
if not driver_name then
return;
end
local driver = stores_available:get(host, driver_name);
- if not driver then
- if driver_name ~= "internal" then
- modulemanager.load(host, "storage_"..driver_name);
- return stores_available:get(host, driver_name);
- else
- return setmetatable({host = host}, default_driver_mt);
- end
+ if driver then return driver; end
+ if driver_name ~= "internal" then
+ modulemanager.load(host, "storage_"..driver_name);
+ return stores_available:get(host, driver_name);
+ else
+ return setmetatable({host = host}, default_driver_mt);
end
end