aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_internal.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2024-02-15 20:28:14 +0100
committerKim Alvefur <zash@zash.se>2024-02-15 20:28:14 +0100
commit1768a2f369ef8ecb108e196917af8bfba11522ca (patch)
tree25e80b04405fe6051661c12fc32c671bedf7106e /plugins/mod_storage_internal.lua
parent331f2d40e1cc454511cc5955ab4f1222a0e19357 (diff)
downloadprosody-1768a2f369ef8ecb108e196917af8bfba11522ca.tar.gz
prosody-1768a2f369ef8ecb108e196917af8bfba11522ca.zip
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.
Diffstat (limited to 'plugins/mod_storage_internal.lua')
-rw-r--r--plugins/mod_storage_internal.lua8
1 files changed, 2 insertions, 6 deletions
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);