Comparison

mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 1819:1b08597b5e6f

mod_storage_xmlarchive: Add support for purging (used when deleting users)
author Kim Alvefur <zash@zash.se>
date Wed, 02 Sep 2015 16:43:34 +0200
parent 1793:152439ca92ee
child 1831:004d3bfc05ea
comparison
equal deleted inserted replaced
1818:8b7bca07f5c0 1819:1b08597b5e6f
222 function provider:open(store, typ) 222 function provider:open(store, typ)
223 if typ ~= "archive" then return nil, "unsupported-store"; end 223 if typ ~= "archive" then return nil, "unsupported-store"; end
224 return setmetatable({ store = store }, archive_mt); 224 return setmetatable({ store = store }, archive_mt);
225 end 225 end
226 226
227 function provider:purge(username)
228 for store in dm.stores(username, module.host) do
229 local dates = dm.list_load(username, module.host, store) or empty;
230 if dates[1] and type(dates[1]) == "string" and dates[1]:match("^%d%d%d%d%-%d%d-%d%d$") then
231 module:log("info", "Store %s looks like an archive store, emptying it...", store);
232 provider:open(store, "archive"):delete(username);
233 end
234 end
235 return true;
236 end
237
227 module:provides("storage", provider); 238 module:provides("storage", provider);