aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-11-09 01:42:01 +0100
committerKim Alvefur <zash@zash.se>2017-11-09 01:42:01 +0100
commitcb209b0f1ecd728ae4b5a5ba48c0699fd6a02ffc (patch)
tree1d16b7c98c03f983328b4b5359970a5afd83a946 /plugins
parentbd3b534ab9ac8ba9fde025fb2dfe4bed34a61a46 (diff)
downloadprosody-cb209b0f1ecd728ae4b5a5ba48c0699fd6a02ffc.tar.gz
prosody-cb209b0f1ecd728ae4b5a5ba48c0699fd6a02ffc.zip
mod_storage_internal: Allow truncating deletion at the beginning or end of an archive store
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_storage_internal.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua
index c29319fc..55a4bfeb 100644
--- a/plugins/mod_storage_internal.lua
+++ b/plugins/mod_storage_internal.lua
@@ -191,6 +191,21 @@ function archive:delete(username, query)
return item.when > query["end"];
end);
end
+ if query.truncate then
+ if query.reverse then
+ -- Before: { 1, 2, 3, 4, 5, }
+ -- After: { 1, 2, 3 }
+ while #items > query.truncate do
+ table.remove(items);
+ end
+ else
+ -- Before: { 1, 2, 3, 4, 5, }
+ -- After: { 3, 4, 5 }
+ while #items > query.truncate do
+ table.remove(items, 1);
+ end
+ end
+ end
end
local count = count_before - #items;
local ok, err = datamanager.list_store(username, host, self.store, items);