From fb8362bbeedd74829271f43bf43aa11f8c79b169 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 7 Jan 2011 11:55:19 +0000 Subject: util.datamanager: Use prosody.paths.data as the initial value for data_path --- util/datamanager.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/datamanager.lua b/util/datamanager.lua index fbdfb581..5aee289d 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -22,6 +22,7 @@ local t_insert = table.insert; local append = require "util.serialization".append; local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end local lfs = require "lfs"; +local prosody = prosody; local raw_mkdir; if prosody.platform == "posix" then @@ -56,7 +57,7 @@ local function mkdir(path) return path; end -local data_path = "data"; +local data_path = prosody.paths.data; local callbacks = {}; ------- API ------------- -- cgit v1.2.3 From b7f05a5336c1d232f749f36989845445a0f72ca3 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 7 Jan 2011 11:56:15 +0000 Subject: prosody: Instead of calling datamanager.set_path(), just ensure prosody.paths.data always contains the correct value (including config) --- prosody | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/prosody b/prosody index 42c3acad..8dcb0096 100755 --- a/prosody +++ b/prosody @@ -183,9 +183,10 @@ function init_global_state() prosody.full_sessions = full_sessions; prosody.hosts = hosts; + local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data"; prosody.paths = { source = CFG_SOURCEDIR, config = CFG_CONFIGDIR, - plugins = CFG_PLUGINDIR, data = CFG_DATADIR }; - + plugins = CFG_PLUGINDIR, data = data_path }; + prosody.arg = _G.arg; prosody.platform = "unknown"; @@ -344,8 +345,6 @@ function load_secondary_libraries() end function init_data_store() - local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data"; - require "util.datamanager".set_data_path(data_path); require "core.storagemanager"; end -- cgit v1.2.3 From 371cf4887ae3a57e6c6832cb7781e10bb926d009 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 7 Jan 2011 11:56:52 +0000 Subject: prosodyctl: Instead of calling datamanager.set_path(), just ensure prosody.paths.data always contains the correct value (including config) --- prosodyctl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/prosodyctl b/prosodyctl index 18f430c5..2c31c641 100755 --- a/prosodyctl +++ b/prosodyctl @@ -109,13 +109,14 @@ end local original_logging_config = config.get("*", "core", "log"); config.set("*", "core", "log", { { levels = { min="info" }, to = "console" } }); +local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data"; +prosody.paths = { source = CFG_SOURCEDIR, config = CFG_CONFIGDIR, + plugins = CFG_PLUGINDIR, data = data_path }; + require "core.loggingmanager" dependencies.log_warnings(); -local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data"; -require "util.datamanager".set_data_path(data_path); - -- Switch away from root and into the prosody user -- local switched_user, current_uid; -- cgit v1.2.3 From 1453a1753f69dbfd122436fca77888328058046b Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 7 Jan 2011 11:57:48 +0000 Subject: mod_storage_sql: Make the 'database' value for the SQLite3 driver relative to the data path --- plugins/mod_storage_sql.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index 3afbab1c..63f75991 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -32,11 +32,18 @@ local connection; local host,user,store = module.host; local params = module:get_option("sql"); +local resolve_relative_path = require "core.configmanager".resolve_relative_path; + do -- process options to get a db connection local DBI = require "DBI"; - params = params or { driver = "SQLite3", database = "prosody.sqlite" }; - assert(params.driver and params.database, "invalid params"); + params = params or { driver = "SQLite3" }; + + if params.driver == "SQLite3" then + params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite"); + end + + assert(params.driver and params.database, "Both the SQL driver and the database need to be specified"); prosody.unlock_globals(); local dbh, err = DBI.Connect( -- cgit v1.2.3