aboutsummaryrefslogtreecommitdiffstats
path: root/util/datamanager.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2012-07-28 21:31:54 +0200
committerKim Alvefur <zash@zash.se>2012-07-28 21:31:54 +0200
commitbf14c1db606376599a6c6c75d234a640ea5519a6 (patch)
tree031e8c43bbcae4c3f1cec07bf594b07c65c0d714 /util/datamanager.lua
parentae1c972cdd64e30c8a5daa5cca9a78bb19a6ba67 (diff)
downloadprosody-bf14c1db606376599a6c6c75d234a640ea5519a6.tar.gz
prosody-bf14c1db606376599a6c6c75d234a640ea5519a6.zip
util.datamanager: Add function for removing all data belonging to a user
Diffstat (limited to 'util/datamanager.lua')
-rw-r--r--util/datamanager.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua
index c29fb416..23a2d74f 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -253,4 +253,18 @@ function list_stores(username, host)
return list;
end
+function purge(username, host)
+ local host_dir = format("%s/%s/", data_path, encode(host));
+ local deleted = 0;
+ 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?
+ end
+ end
+ return deleted > 0, deleted;
+end
+
return _M;