Software /
code /
prosody
Changeset
7115:805d068d2fd5
modulemanager, util.pluginloader: Move logic for locating some module libraries to pluginloader, to fix problems with non-filesystem errors being masked by the second load_code call
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 01 Feb 2016 21:26:15 +0000 |
parents | 7114:51cf09bb74eb |
children | 7116:ecba5fee4867 7117:2b4432cc9c29 |
files | core/moduleapi.lua util/pluginloader.lua |
diffstat | 2 files changed, 16 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/core/moduleapi.lua Sun Jan 31 17:27:15 2016 +0100 +++ b/core/moduleapi.lua Mon Feb 01 21:26:15 2016 +0000 @@ -135,10 +135,7 @@ end function api:require(lib) - local f, n = pluginloader.load_code(self.name, lib..".lib.lua", self.environment); - if not f then - f, n = pluginloader.load_code(lib, lib..".lib.lua", self.environment); - end + local f, n = pluginloader.load_code_ext(self.name, lib, "lib.lua", self.environment); if not f then error("Failed to load plugin library '"..lib.."', error: "..n); end -- FIXME better error message return f(); end
--- a/util/pluginloader.lua Sun Jan 31 17:27:15 2016 +0100 +++ b/util/pluginloader.lua Mon Feb 01 21:26:15 2016 +0000 @@ -55,8 +55,23 @@ return f, path; end +local function load_code_ext(plugin, resource, extension, env) + local content, err = load_resource(plugin, resource.."."..extension); + if not content then + content, err = load_resource(resource, resource.."."..extension); + if not content then + return content, err; + end + end + local path = err; + local f, err = envload(content, "@"..path, env); + if not f then return f, err; end + return f, path; +end + return { load_file = load_file; load_resource = load_resource; load_code = load_code; + load_code_ext = load_code_ext; };