diff options
author | Jonas Schäfer <jonas@wielicki.name> | 2022-04-28 20:40:59 +0200 |
---|---|---|
committer | Jonas Schäfer <jonas@wielicki.name> | 2022-04-28 20:40:59 +0200 |
commit | 8e38a4740edbed793981e8675a8589a95a5c7b01 (patch) | |
tree | 14e28075450e3c11d182657d25698e9f36ef253f /plugins | |
parent | 5c9c12d8d94b405f1622240531b9e240df2486e5 (diff) | |
download | prosody-8e38a4740edbed793981e8675a8589a95a5c7b01.tar.gz prosody-8e38a4740edbed793981e8675a8589a95a5c7b01.zip |
mod_http_file_share: use util.human.io.parse_duration
Updated by Zash, the original patch by Jonas had put the duration
parsing function in util.datetime but MattJ later did the same thing but
differently in f4d7fe919969
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_http_file_share.lua | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua index d9412579..bc7962ad 100644 --- a/plugins/mod_http_file_share.lua +++ b/plugins/mod_http_file_share.lua @@ -19,6 +19,7 @@ local dt = require "prosody.util.datetime"; local hi = require "prosody.util.human.units"; local cache = require "prosody.util.cache"; local lfs = require "lfs"; +local parse_duration = require "prosody.util.human.io".parse_duration; local unknown = math.abs(0/0); local unlimited = math.huge; @@ -39,7 +40,12 @@ local external_base_url = module:get_option_string(module.name .. "_base_url"); local file_size_limit = module:get_option_number(module.name .. "_size_limit", 10 * 1024 * 1024); -- 10 MB local file_types = module:get_option_set(module.name .. "_allowed_file_types", {}); local safe_types = module:get_option_set(module.name .. "_safe_file_types", {"image/*","video/*","audio/*","text/plain"}); -local expiry = module:get_option_number(module.name .. "_expires_after", 7 * 86400); +local expiry_str = module:get_option_string(module.name .. "_expires_after", "1w"); +local expiry, parse_err = parse_duration(expiry_str); +if expiry == nil then + module:log("error", "Could not parse "..module.name.."_expire_after string %q: %s", expiry_str, parse_err); + return false; +end local daily_quota = module:get_option_number(module.name .. "_daily_quota", file_size_limit*10); -- 100 MB / day local total_storage_limit = module:get_option_number(module.name.."_global_quota", unlimited); |