diff mod_storage_s3/mod_storage_s3.lua @ 5696: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
parents b4632d5f840b
children 4a0279c5c7ed
line wrap: on
line diff
--- a/mod_storage_s3/mod_storage_s3.lua	Sat Nov 11 17:01:29 2023 +0100
+++ b/mod_storage_s3/mod_storage_s3.lua	Sat Nov 11 22:26:39 2023 +0100
@@ -281,7 +281,7 @@
 		end
 	end
 	local i = 0;
-	return function()
+	local function get_next()
 		i = i + 1;
 		local item = keys[i];
 		if item == nil then
@@ -293,10 +293,16 @@
 			module:log("error", "%s", err);
 			return nil;
 		end
-		local delay = value:get_child("delay", "urn:xmpp:delay");
+		local when = dt.parse(value:get_child_attr("delay", "urn:xmpp:delay", "stamp"));
 
-		return item.key, value.tags[2], dt.parse(delay.attr.stamp), item.with;
+		if (not query["start"] or query["start"] >= when) and (not query["end"] or query["end"] <= when) then
+			return item.key, value.tags[2], when, item.with;
+		else
+			-- date was correct but not the time
+			return get_next();
+		end
 	end
+	return get_next;
 end
 
 function archive:users()