Software /
code /
prosody-modules
Diff
mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 3587:c24d43ababc6
mod_storage_xmlarchive: Try harder to limit range of time to check
Fixes read of entire index in case where the time range is outside the
range present in the archive.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 07 May 2019 17:10:07 +0200 |
parent | 3585:ddf109d58eff |
child | 3755:bb18a1f5e9d7 |
line wrap: on
line diff
--- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Mon May 06 16:05:00 2019 +0200 +++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Tue May 07 17:10:07 2019 +0200 @@ -109,16 +109,20 @@ local rev = query.reverse; if query.start then local d = dt.date(query.start); - for i = 1, #dates do - if dates[i] >= d then + for i = start_day, last_day, step do + if dates[i] < d then + start_day = i + 1; + elseif dates[i] >= d then start_day = i; break; end end end if query["end"] then local d = dt.date(query["end"]); - for i = #dates, 1, -1 do - if dates[i] <= d then + for i = last_day, start_day, -step do + if dates[i] > d then + last_day = i - 1; + elseif dates[i] <= d then last_day = i; break; end end