aboutsummaryrefslogtreecommitdiffstats
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
commitb242e3d0daf88b0f28205ac7152b02cdb9ef2193 (patch)
tree1d16b7c98c03f983328b4b5359970a5afd83a946
parent22c81936c8674f3b6b84850b754c3357a004c99b (diff)
downloadprosody-b242e3d0daf88b0f28205ac7152b02cdb9ef2193.tar.gz
prosody-b242e3d0daf88b0f28205ac7152b02cdb9ef2193.zip
mod_storage_internal: Allow truncating deletion at the beginning or end of an archive store
-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);