mod_storage_internal: Fix off-by-one when searching archive for
authorKim Alvefur <zash@zash.se>
Thu, 15 Feb 2024 20:28:14 +0100
changeset 13422 2374c7665d0b
parent 13421 b1e2dd6e735b
child 13423 41a587613a0e
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
--- 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);