fixed versioning, again

This commit is contained in:
lqdev 2021-04-25 12:35:00 +02:00
parent 064fc35c77
commit 34e94bb8aa
1 changed files with 17 additions and 16 deletions

View File

@ -599,6 +599,10 @@ end
local function check_plugin_version(filename) local function check_plugin_version(filename)
local info = system.get_file_info(filename)
if info ~= nil and info.type == "dir" then
return true
end
local f = io.open(filename, "r") local f = io.open(filename, "r")
if not f then return false end if not f then return false end
local version_match = false local version_match = false
@ -625,22 +629,19 @@ function core.load_plugins()
local plugin_dir = root_dir .. "/plugins" local plugin_dir = root_dir .. "/plugins"
local files = system.list_dir(plugin_dir) local files = system.list_dir(plugin_dir)
for _, filename in ipairs(files or {}) do for _, filename in ipairs(files or {}) do
local info = system.get_file_info(filename) local basename = filename:match("(.-)%.lua$") or filename
if info ~= nil and info.type == "file" then local version_match = check_plugin_version(plugin_dir .. '/' .. filename)
local basename = filename:match("(.-)%.lua$") or filename if not version_match then
local version_match = check_plugin_version(plugin_dir .. '/' .. filename) core.log_quiet("Version mismatch for plugin %q from %s", basename, plugin_dir)
if not version_match then local ls = refused_list[root_dir == USERDIR and 'userdir' or 'datadir'].plugins
core.log_quiet("Version mismatch for plugin %q from %s", basename, plugin_dir) ls[#ls + 1] = filename
local ls = refused_list[root_dir == USERDIR and 'userdir' or 'datadir'].plugins end
ls[#ls + 1] = filename if version_match and config[basename] ~= false then
end local modname = "plugins." .. basename
if version_match and config[basename] ~= false then local ok = core.try(require, modname)
local modname = "plugins." .. basename if ok then core.log_quiet("Loaded plugin %q from %s", basename, plugin_dir) end
local ok = core.try(require, modname) if not ok then
if ok then core.log_quiet("Loaded plugin %q from %s", basename, plugin_dir) end no_errors = false
if not ok then
no_errors = false
end
end end
end end
end end