# HG changeset patch # User Kim Alvefur # Date 1510188121 -3600 # Node ID b6a7b83f8d87e0420f455fbd1e024fa3eb8964c9 # Parent ff8e122526f4030147c22eeddb91b9b893e01d4b mod_storage_internal: Allow truncating deletion at the beginning or end of an archive store diff -r ff8e122526f4 -r b6a7b83f8d87 plugins/mod_storage_internal.lua --- a/plugins/mod_storage_internal.lua Sun Nov 19 20:51:53 2017 +0100 +++ b/plugins/mod_storage_internal.lua Thu Nov 09 01:42:01 2017 +0100 @@ -191,6 +191,21 @@ 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);