Diff

mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 4648:37ca6109077f

mod_storage_xmlarchive: Support full id range queries
author Kim Alvefur <zash@zash.se>
date Fri, 13 Aug 2021 01:23:34 +0200
parent 4647:b91e40472d68
child 4649:62d41447615d
line wrap: on
line diff
--- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua	Fri Aug 13 01:37:15 2021 +0200
+++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua	Fri Aug 13 01:23:34 2021 +0200
@@ -25,6 +25,7 @@
 archive.caps = {
 	total = false,
 	quota = nil,
+	full_id_range = true;
 };
 
 local is_stanza = st.is_stanza or function (s)
@@ -229,6 +230,7 @@
 	end
 	local items;
 	local first_item, last_item;
+	local stop_at_id;
 	if rev then
 		start_day, step, last_day = last_day, -step, start_day;
 		if query.before then
@@ -246,6 +248,9 @@
 				items = items_;
 			end
 		end
+		if query.after then
+			stop_at_id = query.after;
+		end
 	elseif query.after then
 		local after_day, after_item, items_ = self:_get_idx(username, query.after, dates);
 		if not after_day then
@@ -260,6 +265,11 @@
 			start_day = after_day;
 			items = items_;
 		end
+		if query.before then
+			stop_at_id = query.before;
+		end
+	elseif query.before then
+		stop_at_id = query.before;
 	end
 
 	local date_open, xmlfile;
@@ -322,6 +332,11 @@
 					break;
 				end
 
+				if stop_at_id and stop_at_id == item.id then
+					if xmlfile then xmlfile:close(); end
+					return;
+				end
+
 				if  (not q_with or i_with == q_with)
 				and (not q_start or i_when >= q_start)
 				and (not q_end or i_when <= q_end) then