Comparison

mod_storage_s3/mod_storage_s3.lua @ 5719:66986f5271c3

mod_storage_s3: Skip archive items matching on date but not full datetime Since it only encodes dates in paths, it would have returned items from outside the specified start..end range if they were from earlier or later in the same (UTC) day.
author Kim Alvefur <zash@zash.se>
date Sat, 11 Nov 2023 22:26:39 +0100
parent 5718:b4632d5f840b
child 5720:4a0279c5c7ed
comparison
equal deleted inserted replaced
5718:b4632d5f840b 5719:66986f5271c3
279 if not found and key[6] == query["after"] then 279 if not found and key[6] == query["after"] then
280 found = not found 280 found = not found
281 end 281 end
282 end 282 end
283 local i = 0; 283 local i = 0;
284 return function() 284 local function get_next()
285 i = i + 1; 285 i = i + 1;
286 local item = keys[i]; 286 local item = keys[i];
287 if item == nil then 287 if item == nil then
288 return nil; 288 return nil;
289 end 289 end
291 local value, err = async.wait_for(new_request(self, "GET", self:_path(username or "@", item.date, nil, item.with, item.key)):next(on_result)); 291 local value, err = async.wait_for(new_request(self, "GET", self:_path(username or "@", item.date, nil, item.with, item.key)):next(on_result));
292 if not value then 292 if not value then
293 module:log("error", "%s", err); 293 module:log("error", "%s", err);
294 return nil; 294 return nil;
295 end 295 end
296 local delay = value:get_child("delay", "urn:xmpp:delay"); 296 local when = dt.parse(value:get_child_attr("delay", "urn:xmpp:delay", "stamp"));
297 297
298 return item.key, value.tags[2], dt.parse(delay.attr.stamp), item.with; 298 if (not query["start"] or query["start"] >= when) and (not query["end"] or query["end"] <= when) then
299 end 299 return item.key, value.tags[2], when, item.with;
300 else
301 -- date was correct but not the time
302 return get_next();
303 end
304 end
305 return get_next;
300 end 306 end
301 307
302 function archive:users() 308 function archive:users()
303 return it.unique(keyval.users(self)); 309 return it.unique(keyval.users(self));
304 end 310 end