Changeset

4096:3b991ceb228e

mod_storage_sql: Make the 'database' value for the SQLite3 driver relative to the data path
author Matthew Wild <mwild1@gmail.com>
date Fri, 07 Jan 2011 11:57:48 +0000
parents 4095:6ad7ed619d37
children 4097:2d3866aed062 4101:06778bc27d53
files plugins/mod_storage_sql.lua
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua	Fri Jan 07 11:56:52 2011 +0000
+++ b/plugins/mod_storage_sql.lua	Fri Jan 07 11:57:48 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(