Mercurial > prosody-modules
changeset 4976:75b6e5df65f9
various: Improve error reporting if missing file server module on 0.12
If there is some error loading net.http.files then it would be swallowed
by the pcall and then it would proceed to trying mod_http_files, which
might cause unexpected behavior on 0.12
Ref #1765
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 18 Jul 2022 22:47:54 +0200 |
parents | 733e5513f691 |
children | 3bd725430f40 |
files | mod_conversejs/mod_conversejs.lua mod_http_libjs/mod_http_libjs.lua mod_http_upload/mod_http_upload.lua mod_invite/mod_invite.lua mod_invites_page/mod_invites_page.lua mod_jsxc/mod_jsxc.lua mod_password_reset/mod_password_reset.lua mod_register_apps/mod_register_apps.lua mod_welcome_page/mod_welcome_page.lua |
diffstat | 9 files changed, 19 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_conversejs/mod_conversejs.lua Mon Jul 18 13:58:27 2022 +0200 +++ b/mod_conversejs/mod_conversejs.lua Mon Jul 18 22:47:54 2022 +0200 @@ -29,11 +29,11 @@ local resources = module:get_option_path("conversejs_resources"); if resources then local serve; - if not pcall(function() + if prosody.process_type == "prosody" then -- Prosody >= trunk / 0.12 local http_files = require "net.http.files"; serve = http_files.serve; - end) then + else -- Prosody <= 0.11 serve = module:depends "http_files".serve; end
--- a/mod_http_libjs/mod_http_libjs.lua Mon Jul 18 13:58:27 2022 +0200 +++ b/mod_http_libjs/mod_http_libjs.lua Mon Jul 18 22:47:54 2022 +0200 @@ -4,10 +4,10 @@ }; local serve; -if not pcall(function () +if prosody.process_type == "prosody" then local http_files = require "net.http.files"; serve = http_files.serve; -end) then +else serve = module:depends"http_files".serve; end
--- a/mod_http_upload/mod_http_upload.lua Mon Jul 18 13:58:27 2022 +0200 +++ b/mod_http_upload/mod_http_upload.lua Mon Jul 18 22:47:54 2022 +0200 @@ -57,9 +57,9 @@ local http_files; -if not pcall(function () +if prosody.process_type == "prosody" then http_files = require "net.http.files"; -end) then +else http_files = module:depends"http_files"; end
--- a/mod_invite/mod_invite.lua Mon Jul 18 13:58:27 2022 +0200 +++ b/mod_invite/mod_invite.lua Mon Jul 18 22:47:54 2022 +0200 @@ -13,10 +13,10 @@ local inviter_storage = module:open_store("inviter"); local serve; -if not pcall(function () +if prosody.process_type == "prosody" then local http_files = require "net.http.files"; serve = http_files.serve; -end) then +else serve = module:depends"http_files".serve; end
--- a/mod_invites_page/mod_invites_page.lua Mon Jul 18 13:58:27 2022 +0200 +++ b/mod_invites_page/mod_invites_page.lua Mon Jul 18 22:47:54 2022 +0200 @@ -33,9 +33,10 @@ -- Load HTTP-serving dependencies if prosody.shutdown then -- not if running under prosodyctl module:depends("http"); - if not pcall(function () + + if prosody.process_type == "prosody" then http_files = require "net.http.files"; - end) then + else http_files = module:depends"http_files"; end end
--- a/mod_jsxc/mod_jsxc.lua Mon Jul 18 13:58:27 2022 +0200 +++ b/mod_jsxc/mod_jsxc.lua Mon Jul 18 22:47:54 2022 +0200 @@ -20,11 +20,11 @@ local resources = module:get_option_path("jsxc_resources"); if resources then local serve; - if not pcall(function() + if prosody.process_type == "prosody" then -- Prosody >= trunk / 0.12 local http_files = require "net.http.files"; serve = http_files.serve; - end) then + else -- Prosody <= 0.11 serve = module:depends "http_files".serve; end
--- a/mod_password_reset/mod_password_reset.lua Mon Jul 18 13:58:27 2022 +0200 +++ b/mod_password_reset/mod_password_reset.lua Mon Jul 18 22:47:54 2022 +0200 @@ -14,10 +14,10 @@ local max_token_age = module:get_option_number("password_reset_validity", 86400); local serve; -if not pcall(function () +if prosody.process_type == "prosody" then local http_files = require "net.http.files"; serve = http_files.serve; -end) then +else serve = module:depends"http_files".serve; end
--- a/mod_register_apps/mod_register_apps.lua Mon Jul 18 13:58:27 2022 +0200 +++ b/mod_register_apps/mod_register_apps.lua Mon Jul 18 22:47:54 2022 +0200 @@ -1,10 +1,10 @@ -- luacheck: ignore 631 module:depends("http"); local http_files -if not pcall(function() +if prosody.process_type == "prosody" then -- Prosody >= 0.12 http_files = require "net.http.files"; -end) then +else -- Prosody <= 0.11 http_files = module:depends "http_files"; end
--- a/mod_welcome_page/mod_welcome_page.lua Mon Jul 18 13:58:27 2022 +0200 +++ b/mod_welcome_page/mod_welcome_page.lua Mon Jul 18 22:47:54 2022 +0200 @@ -62,10 +62,10 @@ end local http_files -if not pcall(function() +if prosody.process_type == "prosody" then -- Prosody >= 0.12 http_files = require "net.http.files"; -end) then +else -- Prosody <= 0.11 http_files = module:depends "http_files"; end