Software / code / prosody
Diff
plugins/mod_storage_internal.lua @ 13418:2374c7665d0b
mod_storage_internal: Fix off-by-one when searching archive for
Fixes a test case provided by MattJ where the very first item matched by
a 'start' timestamp was not returned.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 15 Feb 2024 20:28:14 +0100 |
| parent | 13402:6877786d73d7 |
| child | 13761:8f516d20d288 |
line wrap: on
line diff
--- a/plugins/mod_storage_internal.lua Thu Jan 11 07:54:11 2024 +0100 +++ b/plugins/mod_storage_internal.lua Thu Feb 15 20:28:14 2024 +0100 @@ -200,15 +200,11 @@ end if query.start then if not query.reverse then - local wi, exact = binary_search(list, function(item) + local wi = binary_search(list, function(item) local when = item.when or datetime.parse(item.attr.stamp); return query.start - when; end); - if exact then - i = wi - 1; - elseif wi then - i = wi; - end + i = wi - 1; else iter = it.filter(function(item) local when = item.when or datetime.parse(item.attr.stamp);