diff options
author | Matthew Wild <mwild1@gmail.com> | 2011-01-07 11:59:05 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2011-01-07 11:59:05 +0000 |
commit | 4fac07320796a04ea2596f7c0ceaabaa608bd532 (patch) | |
tree | abd3446bd90c35e108a9336c9865f85d34eac4f5 | |
parent | 79bcb5c7cfed2a2ea89d2bac48bacb9e9447d599 (diff) | |
parent | 1453a1753f69dbfd122436fca77888328058046b (diff) | |
download | prosody-4fac07320796a04ea2596f7c0ceaabaa608bd532.tar.gz prosody-4fac07320796a04ea2596f7c0ceaabaa608bd532.zip |
Merge 0.8->trunk
-rw-r--r-- | plugins/mod_storage_sql.lua | 11 | ||||
-rwxr-xr-x | prosody | 7 | ||||
-rwxr-xr-x | prosodyctl | 7 | ||||
-rw-r--r-- | util/datamanager.lua | 3 |
4 files changed, 18 insertions, 10 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( @@ -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 @@ -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; 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 ------------- |