aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_internal.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-05-05 08:12:16 +0200
committerKim Alvefur <zash@zash.se>2019-05-05 08:12:16 +0200
commit637b52a13e2c9e655a2595a4d8e274280e2fd612 (patch)
treec44102e5bb6625d914cef370da3562facd4cfc55 /plugins/mod_storage_internal.lua
parenta371d01137d44a43cbeabe2590174fc36053bb2a (diff)
downloadprosody-637b52a13e2c9e655a2595a4d8e274280e2fd612.tar.gz
prosody-637b52a13e2c9e655a2595a4d8e274280e2fd612.zip
mod_storage_internal,memory: Only return total count if requested
Diffstat (limited to 'plugins/mod_storage_internal.lua')
-rw-r--r--plugins/mod_storage_internal.lua17
1 files changed, 11 insertions, 6 deletions
diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua
index aa5c3c8a..f921747e 100644
--- a/plugins/mod_storage_internal.lua
+++ b/plugins/mod_storage_internal.lua
@@ -124,11 +124,14 @@ function archive:find(username, query)
if not items then
if err then
return items, err;
- else
- return function () end, 0;
+ elseif query then
+ if query.total then
+ return function () end, 0;
+ end
end
+ return function () end;
end
- local count = #items;
+ local count = nil;
local i = 0;
if query then
items = array(items);
@@ -152,11 +155,13 @@ function archive:find(username, query)
return item.when <= query["end"];
end);
end
- count = #items;
+ if query.total then
+ count = #items;
+ end
if query.reverse then
items:reverse();
if query.before then
- for j = 1, count do
+ for j = 1, #items do
if (items[j].key or tostring(j)) == query.before then
i = j;
break;
@@ -164,7 +169,7 @@ function archive:find(username, query)
end
end
elseif query.after then
- for j = 1, count do
+ for j = 1, #items do
if (items[j].key or tostring(j)) == query.after then
i = j;
break;