Software /
code /
prosody
Changeset
4097:2d3866aed062
Merge 0.8->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 07 Jan 2011 11:59:05 +0000 |
parents | 4092:d78d5038d144 (current diff) 4096:3b991ceb228e (diff) |
children | 4098:7d687c348295 |
files | |
diffstat | 4 files changed, 18 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua Fri Jan 07 05:11:17 2011 +0000 +++ b/plugins/mod_storage_sql.lua Fri Jan 07 11:59:05 2011 +0000 @@ -32,11 +32,18 @@ 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(
--- a/prosody Fri Jan 07 05:11:17 2011 +0000 +++ b/prosody Fri Jan 07 11:59:05 2011 +0000 @@ -183,9 +183,10 @@ 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 @@ 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
--- a/prosodyctl Fri Jan 07 05:11:17 2011 +0000 +++ b/prosodyctl Fri Jan 07 11:59:05 2011 +0000 @@ -109,13 +109,14 @@ 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;
--- a/util/datamanager.lua Fri Jan 07 05:11:17 2011 +0000 +++ b/util/datamanager.lua Fri Jan 07 11:59:05 2011 +0000 @@ -22,6 +22,7 @@ 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 @@ return path; end -local data_path = "data"; +local data_path = prosody.paths.data; local callbacks = {}; ------- API -------------