Software /
code /
prosody
Diff
plugins/mod_storage_internal.lua @ 8393:b6a7b83f8d87
mod_storage_internal: Allow truncating deletion at the beginning or end of an archive store
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 09 Nov 2017 01:42:01 +0100 |
parent | 8310:1759491b53db |
child | 8394:4892c22403d5 |
line wrap: on
line diff
--- 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);