mirror of
https://github.com/appgurueu/modlib.git
synced 2024-12-22 21:32:27 +01:00
Fix SQLite3 requiring for trusted modlib
This commit is contained in:
parent
eb3a3b2960
commit
b8d8d3c4d1
6
init.lua
6
init.lua
@ -132,6 +132,12 @@ modlib = setmetatable({
|
||||
modlib.mod = minetest and dofile(get_resource(modlib.modname, "mod.lua"))
|
||||
|
||||
if minetest then
|
||||
local ie = minetest.request_insecure_environment()
|
||||
if ie then
|
||||
-- Force load persistence namespace to pass insecure require
|
||||
-- TODO currently no need to set _G.require, lsqlite3 loads no dependencies that way
|
||||
modlib.persistence = assert(loadfile(get_resource"persistence.lua"))(ie.require)
|
||||
end
|
||||
modlib.conf.build_setting_tree()
|
||||
modlib.mod.get_resource = get_resource
|
||||
end
|
||||
|
@ -1,3 +1,4 @@
|
||||
local require = ... or require
|
||||
-- TODO consider moving serializers in this namespace
|
||||
local function load(module_name)
|
||||
return assert(loadfile(modlib.mod.get_resource(modlib.modname, "persistence", module_name .. ".lua")))
|
||||
@ -9,7 +10,13 @@ local _ENV = setmetatable({}, {__index = function(_ENV, module_name)
|
||||
return module
|
||||
end
|
||||
if module_name == "sqlite3" then
|
||||
local module = load(module_name)
|
||||
local func = load(module_name)
|
||||
local module = function(sqlite3)
|
||||
if sqlite3 then
|
||||
return func(sqlite3)
|
||||
end
|
||||
return func(require"lsqlite3")
|
||||
end
|
||||
_ENV[module_name] = module
|
||||
return module
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
local assert, error, math_huge, modlib, minetest, setmetatable, type, table_insert, table_sort, pairs, ipairs
|
||||
= assert, error, math.huge, modlib, minetest, setmetatable, type, table.insert, table.sort, pairs, ipairs
|
||||
|
||||
local sqlite3 = ... or require"lsqlite3"
|
||||
local sqlite3 = ...
|
||||
|
||||
--! experimental
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user