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(-) (limited to 'plugins') 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