Mercurial > prosody-hg
comparison 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 |
| parents | 6877786d73d7 |
| children | 8f516d20d288 |
comparison
equal
deleted
inserted
replaced
| 13417:b1e2dd6e735b | 13418:2374c7665d0b |
|---|---|
| 198 return item.with == query.with; | 198 return item.with == query.with; |
| 199 end, iter); | 199 end, iter); |
| 200 end | 200 end |
| 201 if query.start then | 201 if query.start then |
| 202 if not query.reverse then | 202 if not query.reverse then |
| 203 local wi, exact = binary_search(list, function(item) | 203 local wi = binary_search(list, function(item) |
| 204 local when = item.when or datetime.parse(item.attr.stamp); | 204 local when = item.when or datetime.parse(item.attr.stamp); |
| 205 return query.start - when; | 205 return query.start - when; |
| 206 end); | 206 end); |
| 207 if exact then | 207 i = wi - 1; |
| 208 i = wi - 1; | |
| 209 elseif wi then | |
| 210 i = wi; | |
| 211 end | |
| 212 else | 208 else |
| 213 iter = it.filter(function(item) | 209 iter = it.filter(function(item) |
| 214 local when = item.when or datetime.parse(item.attr.stamp); | 210 local when = item.when or datetime.parse(item.attr.stamp); |
| 215 return when >= query.start; | 211 return when >= query.start; |
| 216 end, iter); | 212 end, iter); |
