diff options
author | Kim Alvefur <zash@zash.se> | 2021-02-07 19:23:33 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-02-07 19:23:33 +0100 |
commit | f0069378bd6e58d9439e0156a3c216cbd2bd9360 (patch) | |
tree | 96536ef5d18af6298d7839f335eb63bf2ddf2a6d /util | |
parent | 0f16ee66e2ab2e592f3d153435fcc34ccca2646b (diff) | |
download | prosody-f0069378bd6e58d9439e0156a3c216cbd2bd9360.tar.gz prosody-f0069378bd6e58d9439e0156a3c216cbd2bd9360.zip |
util.datamanager: Support iterating over any file extension
The 'typ' argument to all other functions is the actual file extension,
but not here for some reason.
May need this for iterating over the .bin files created by
mod_http_file_share in the future.
Diffstat (limited to 'util')
-rw-r--r-- | util/datamanager.lua | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua index 348831e0..b8829de1 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -320,7 +320,7 @@ local type_map = { } local function users(host, store, typ) -- luacheck: ignore 431/store - typ = type_map[typ or "keyval"]; + typ = "."..(type_map[typ or "keyval"] or typ); local store_dir = format("%s/%s/%s", data_path, encode(host), store_encode(store)); local mode, err = lfs.attributes(store_dir, "mode"); @@ -330,9 +330,8 @@ local function users(host, store, typ) -- luacheck: ignore 431/store local next, state = lfs.dir(store_dir); -- luacheck: ignore 431/next 431/state return function(state) -- luacheck: ignore 431/state for node in next, state do - local file, ext = node:match("^(.*)%.([dalist]+)$"); - if file and ext == typ then - return decode(file); + if node:sub(-#typ, -1) == typ then + return decode(node:sub(1, -#typ-1)); end end end, state; |