X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fdatamanager.lua;h=a107d95c26904a697a949157f8caa706ca46a696;hb=533fc1fa57ce10fc0821f8edaeb247f2710a543c;hp=4a4d62b3c098519f361912162f9a73e30209c960;hpb=cc56df0ce28ec6173ef29eed57060108c32b0fab;p=prosody.git diff --git a/util/datamanager.lua b/util/datamanager.lua index 4a4d62b3..a107d95c 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -163,7 +163,7 @@ local function atomic_store(filename, data) return nil, msg; end -if prosody.platform ~= "posix" then +if prosody and prosody.platform ~= "posix" then -- os.rename does not overwrite existing files on Windows -- TODO We could use Transactional NTFS on Vista and above function atomic_store(filename, data) @@ -293,7 +293,7 @@ function users(host, store, 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", "%s", err or (store_dir .. " does not exist")) end end local next, state = lfs.dir(store_dir); return function(state) @@ -348,8 +348,12 @@ end function purge(username, host) local host_dir = format("%s/%s/", data_path, encode(host)); + local ok, iter, state, var = pcall(lfs.dir, host_dir); + if not ok then + return ok, iter; + end local errs = {}; - for file in lfs.dir(host_dir) do + for file in iter, state, var do if lfs.attributes(host_dir..file, "mode") == "directory" then local store = decode(file); local ok, err = do_remove(getpath(username, host, store));