aboutsummaryrefslogtreecommitdiffstats
path: root/util/datamanager.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2012-08-26 20:53:40 +0200
committerKim Alvefur <zash@zash.se>2012-08-26 20:53:40 +0200
commit4e9c9163beba59ad1f623fd592272dc5936634a7 (patch)
tree10b4f9b15956a780b6a061d4c96344df5cabff85 /util/datamanager.lua
parentfebff04cfd53755194c4460aad3c1199ac68c87f (diff)
downloadprosody-4e9c9163beba59ad1f623fd592272dc5936634a7.tar.gz
prosody-4e9c9163beba59ad1f623fd592272dc5936634a7.zip
util.datamanager: Ignore errors if the file is gone after removing it
Diffstat (limited to 'util/datamanager.lua')
-rw-r--r--util/datamanager.lua17
1 files changed, 13 insertions, 4 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua
index b745cd39..17c614ed 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -309,6 +309,14 @@ function list_stores(username, host)
return list;
end
+local function do_remove(path)
+ local ok, err = os_remove(path);
+ if not ok and lfs.attributes(path, "mode") then
+ return ok, err;
+ end
+ return true
+end
+
function purge(username, host)
local host_dir = format("%s/%s/", data_path, encode(host));
local deleted = 0;
@@ -316,10 +324,11 @@ function purge(username, host)
for file in lfs.dir(host_dir) do
if lfs.attributes(host_dir..file, "mode") == "directory" then
local store = decode(file);
- 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
+ local ok, err = do_remove(getpath(username, host, store));
+ if not ok then errs[#errs+1] = err; end
+
+ local ok, err = do_remove(getpath(username, host, store, "list"));
+ if not ok then errs[#errs+1] = err; end
end
end
return #errs == 0, t_concat(errs, ", ");