From 1768a2f369ef8ecb108e196917af8bfba11522ca Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 15 Feb 2024 20:28:14 +0100 Subject: 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. --- plugins/mod_storage_internal.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua index deab7dfd..a43dd272 100644 --- a/plugins/mod_storage_internal.lua +++ b/plugins/mod_storage_internal.lua @@ -200,15 +200,11 @@ function archive:find(username, query) 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); -- cgit v1.2.3