From 50ed262a8f77e46e473a6db27247c931724f40e6 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sun, 12 Dec 2010 05:13:02 +0500 Subject: storagemanager: Fixed a nil global access. --- core/storagemanager.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'core/storagemanager.lua') diff --git a/core/storagemanager.lua b/core/storagemanager.lua index 0857baf4..d3e3e807 100644 --- a/core/storagemanager.lua +++ b/core/storagemanager.lua @@ -25,6 +25,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); -- cgit v1.2.3 From 980df08b94f8ba0b3cb744b3ce4287c7be303a06 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sun, 12 Dec 2010 05:14:35 +0500 Subject: storagemanager: Hook "host-activated", to make sure we are notified about data drivers. --- core/storagemanager.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'core/storagemanager.lua') diff --git a/core/storagemanager.lua b/core/storagemanager.lua index d3e3e807..db540042 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") @@ -36,6 +37,7 @@ 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 -- cgit v1.2.3 From 6771ad9d2998f4589ebacb819b89f133fb8c7970 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sun, 12 Dec 2010 06:15:08 +0500 Subject: storagemanager: When we have a cached data driver, we are supposed to use it. --- core/storagemanager.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'core/storagemanager.lua') diff --git a/core/storagemanager.lua b/core/storagemanager.lua index db540042..e0c12190 100644 --- a/core/storagemanager.lua +++ b/core/storagemanager.lua @@ -44,13 +44,12 @@ local function load_driver(host, driver_name) 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 -- cgit v1.2.3