aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2012-08-25 01:21:41 +0200
committerKim Alvefur <zash@zash.se>2012-08-25 01:21:41 +0200
commit40c2d9048103e0b42d60a87d763cf7826e217a62 (patch)
tree0f44f5daf715f695a2ad93035f9b3266fe7ad4fb /util
parent9059e2a4fe09ec771bc94d46e566b665dc8f1986 (diff)
downloadprosody-40c2d9048103e0b42d60a87d763cf7826e217a62.tar.gz
prosody-40c2d9048103e0b42d60a87d763cf7826e217a62.zip
util.datamanager: Collect errors when deleting all stores of a user, but ignore "no such file"
Diffstat (limited to 'util')
-rw-r--r--util/datamanager.lua10
1 files changed, 6 insertions, 4 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua
index 9f7600ee..b745cd39 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -312,15 +312,17 @@ end
function purge(username, host)
local host_dir = format("%s/%s/", data_path, encode(host));
local deleted = 0;
+ local errs = {};
for file in lfs.dir(host_dir) do
if lfs.attributes(host_dir..file, "mode") == "directory" then
local store = decode(file);
- deleted = deleted + (os_remove(getpath(username, host, store)) and 1 or 0);
- deleted = deleted + (os_remove(getpath(username, host, store, "list")) and 1 or 0);
- -- We this will generate loads of "No such file or directory", but do we care?
+ local ok, err = os_remove(getpath(username, host, store));
+ if not ok and not err:lower():match("no such") then errs[#errs+1] = err; end
+ local ok, err = os_remove(getpath(username, host, store, "list"));
+ if not ok and not err:lower():match("no such") then errs[#errs+1] = err; end
end
end
- return deleted > 0, deleted;
+ return #errs == 0, t_concat(errs, ", ");
end
return _M;