Diff

mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 3572:7700c9537e90

mod_storage_xmlarchive: Return error if range request reference missing items (see #1325)
author Kim Alvefur <zash@zash.se>
date Fri, 03 May 2019 21:07:51 +0200
parent 3571:f5ea0b886c7c
child 3585:ddf109d58eff
line wrap: on
line diff
--- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua	Fri May 03 18:59:38 2019 +0200
+++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua	Fri May 03 21:07:51 2019 +0200
@@ -129,7 +129,9 @@
 		start_day, step, last_day = last_day, -step, start_day;
 		if query.before then
 			local before_day, before_item, items_ = self:_get_idx(username, query.before, dates);
-			if before_day and before_day <= start_day then
+			if not before_day then
+				return nil, "item-not-found";
+			elseif before_day <= start_day then
 				if before_item then
 					first_item = before_item - 1;
 				else
@@ -142,7 +144,9 @@
 		end
 	elseif query.after then
 		local after_day, after_item, items_ = self:_get_idx(username, query.after, dates);
-		if after_day and after_day >= start_day then
+		if not after_day then
+			return nil, "item-not-found";
+		elseif after_day >= start_day then
 			if after_item then
 				first_item = after_item + 1;
 			else