diff options
author | Kim Alvefur <zash@zash.se> | 2023-07-22 16:15:48 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2023-07-22 16:15:48 +0200 |
commit | 51daea2530acdb6017d49873900d61f46f7b9f2b (patch) | |
tree | 267e8854c6291e049fe0032db2d0f15609dbe73d | |
parent | 0df158712dfc0f3c2decfc2517d6a4fadf284a9d (diff) | |
download | prosody-51daea2530acdb6017d49873900d61f46f7b9f2b.tar.gz prosody-51daea2530acdb6017d49873900d61f46f7b9f2b.zip |
mod_storage_sql: Spell out missing dependencies
Using util.dependencies appeared to cause problems with running tests in
Busted, so this also removes that and uses pcall directly.
-rw-r--r-- | plugins/mod_storage_sql.lua | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index a1cef29c..f5569f7c 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -1,11 +1,8 @@ -- luacheck: ignore 212/self -local deps = require "prosody.util.dependencies"; local cache = require "prosody.util.cache"; local json = require "prosody.util.json"; -local sqlite = deps.softreq "prosody.util.sqlite3"; -local dbisql = (sqlite and deps.softreq or require) "prosody.util.sql"; local xml_parse = require "prosody.util.xml".parse; local uuid = require "prosody.util.uuid"; local resolve_relative_path = require "prosody.util.paths".resolve_relative_path; @@ -14,6 +11,22 @@ local jid_join = require "prosody.util.jid".join; local is_stanza = require"prosody.util.stanza".is_stanza; local t_concat = table.concat; +local have_dbisql, dbisql = pcall(require, "prosody.util.sql"); +local have_sqlite, sqlite = pcall(require, "prosody.util.sqlite3"); +if not have_dbisql then + module:log("debug", "Could not load LuaDBI, error was: %s", dbisql) + dbisql = nil; +end +if not have_sqlite then + module:log("debug", "Could not load LuaSQLite3, error was: %s", sqlite) + sqlite = nil; +end +if not (have_dbisql or have_sqlite) then + module:log("error", "LuaDBI or LuaSQLite3 are required for using SQL databases but neither are installed"); + module:log("error", "Please install at least one of LuaDBI and LuaSQLite3. See https://prosody.im/doc/depends"); + error("No SQL library available") +end + local noop = function() end local unpack = table.unpack; local function iterator(result) |