--- a/mod_storage_muc_log/mod_storage_muc_log.lua Tue Jan 20 11:02:14 2015 +0000
+++ b/mod_storage_muc_log/mod_storage_muc_log.lua Sun Jan 25 13:04:02 2015 +0100
@@ -1,3 +1,6 @@
+-- Copyright (C) 2014 Kim Alvefur
+--
+-- This file is MIT/X11 licensed.
local datamanager = require"core.storagemanager".olddm;
local xml_parse = require"util.xml".parse;
@@ -147,6 +150,25 @@
end);
end
+function driver:delete(node, query)
+ local start_date = query and query.start and os_date(datef, query.start) or "000000";
+ local end_date = query and query["end"] and os_date(datef, query["end"]) or "999999";
+
+ local path = datamanager.getpath(node, host, datastore):match("(.*)/");
+ local ok, iter, state, var = pcall(lfs.dir, path);
+ if not ok then
+ module:log("warn", iter);
+ return nil, iter;
+ end
+
+ for dir in iter, state, var do
+ if dir > start_date and dir < end_date then
+ data_store(node, host, datastore .. "/" .. dir, nil);
+ end
+ end
+ return true;
+end
+
function open(_, store, typ)
if typ ~= "archive" then
return nil, "unsupported-store";
@@ -154,4 +176,6 @@
return setmetatable({ store = store, type = typ }, driver_mt);
end
+purge = driver.delete;
+
module:provides "storage";