mod_storage_memory: Return error if 'before' or 'after' are not found (partial fix for #1325)

This commit is contained in:
Kim Alvefur 2019-03-05 00:16:41 +01:00
parent b772308c93
commit f456f0c03e

View file

@ -127,20 +127,30 @@ function archive_store:find(username, query)
if query.reverse then
items:reverse();
if query.before then
local found = false;
for j = 1, #items do
if (items[j].key or tostring(j)) == query.before then
found = true;
i = j;
break;
end
end
if not found then
return nil, "item-not-found";
end
end
elseif query.after then
local found = false;
for j = 1, #items do
if (items[j].key or tostring(j)) == query.after then
found = true;
i = j;
break;
end
end
if not found then
return nil, "item-not-found";
end
end
if query.limit and #items - i > query.limit then
items[i+query.limit+1] = nil;