diff options
Diffstat (limited to 'util/datamanager.lua')
-rw-r--r-- | util/datamanager.lua | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua index 0d7060b7..b8829de1 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -24,7 +24,7 @@ local t_concat = table.concat; local envloadfile = require"util.envload".envloadfile; local serialize = require "util.serialization".serialize; local lfs = require "lfs"; --- Extract directory seperator from package.config (an undocumented string that comes with lua) +-- Extract directory separator from package.config (an undocumented string that comes with lua) local path_separator = assert ( package.config:match ( "^([^\n]+)" ) , "package.config not in standard form" ) local prosody = prosody; @@ -157,7 +157,8 @@ end local function atomic_store(filename, data) local scratch = filename.."~"; - local f, ok, msg, errno; + local f, ok, msg, errno; -- luacheck: ignore errno + -- TODO return util.error with code=errno? f, msg, errno = io_open(scratch, "w"); if not f then @@ -319,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"); @@ -329,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; @@ -343,7 +343,7 @@ local function stores(username, host, typ) local mode, err = lfs.attributes(store_dir, "mode"); if not mode then - return function() log("debug", err or (store_dir .. " does not exist")) end + return function() log("debug", "Could not iterate over stores in %s: %s", store_dir, err); end end local next, state = lfs.dir(store_dir); -- luacheck: ignore 431/next 431/state return function(state) -- luacheck: ignore 431/state |