aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_memory.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
commit200664ab8a16a7f5a4d4a2de878c9f94cbeb4a8f (patch)
treec44102e5bb6625d914cef370da3562facd4cfc55 /plugins/mod_storage_memory.lua
parentb3741ec9ef19f4cc5dfb0bbc5832d632339dadcc (diff)
downloadprosody-200664ab8a16a7f5a4d4a2de878c9f94cbeb4a8f.tar.gz
prosody-200664ab8a16a7f5a4d4a2de878c9f94cbeb4a8f.zip
mod_storage_internal,memory: Only return total count if requested
Diffstat (limited to 'plugins/mod_storage_memory.lua')
-rw-r--r--plugins/mod_storage_memory.lua17
1 files changed, 12 insertions, 5 deletions
diff --git a/plugins/mod_storage_memory.lua b/plugins/mod_storage_memory.lua
index dde2d571..4655cb3a 100644
--- a/plugins/mod_storage_memory.lua
+++ b/plugins/mod_storage_memory.lua
@@ -90,9 +90,14 @@ end
function archive_store:find(username, query)
local items = self.store[username or NULL];
if not items then
- return function () end, 0;
+ if 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():append(items);
@@ -116,11 +121,13 @@ function archive_store: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;
@@ -128,7 +135,7 @@ function archive_store: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;