Software /
code /
prosody-modules
Comparison
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 |
comparison
equal
deleted
inserted
replaced
3586:796b29911747 | 3587:c24d43ababc6 |
---|---|
107 local start_day, step, last_day = 1, 1, #dates; | 107 local start_day, step, last_day = 1, 1, #dates; |
108 local count = 0; | 108 local count = 0; |
109 local rev = query.reverse; | 109 local rev = query.reverse; |
110 if query.start then | 110 if query.start then |
111 local d = dt.date(query.start); | 111 local d = dt.date(query.start); |
112 for i = 1, #dates do | 112 for i = start_day, last_day, step do |
113 if dates[i] >= d then | 113 if dates[i] < d then |
114 start_day = i + 1; | |
115 elseif dates[i] >= d then | |
114 start_day = i; break; | 116 start_day = i; break; |
115 end | 117 end |
116 end | 118 end |
117 end | 119 end |
118 if query["end"] then | 120 if query["end"] then |
119 local d = dt.date(query["end"]); | 121 local d = dt.date(query["end"]); |
120 for i = #dates, 1, -1 do | 122 for i = last_day, start_day, -step do |
121 if dates[i] <= d then | 123 if dates[i] > d then |
124 last_day = i - 1; | |
125 elseif dates[i] <= d then | |
122 last_day = i; break; | 126 last_day = i; break; |
123 end | 127 end |
124 end | 128 end |
125 end | 129 end |
126 local items; | 130 local items; |