diff options
author | Kim Alvefur <zash@zash.se> | 2019-05-05 08:12:16 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-05-05 08:12:16 +0200 |
commit | 637b52a13e2c9e655a2595a4d8e274280e2fd612 (patch) | |
tree | c44102e5bb6625d914cef370da3562facd4cfc55 /plugins/mod_storage_internal.lua | |
parent | a371d01137d44a43cbeabe2590174fc36053bb2a (diff) | |
download | prosody-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.lua | 17 |
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; |