Commit 045bfa65 authored by Tristan Cavelier's avatar Tristan Cavelier

gidstorage does not stop if storage is empty fix

parent 4ead8961
...@@ -600,7 +600,7 @@ ...@@ -600,7 +600,7 @@
*/ */
that.allDocs = function (command, param, options) { that.allDocs = function (command, param, options) {
/*jslint unparam: true */ /*jslint unparam: true */
var include_docs, limit_start, limit_length, rows, i = 0; var include_docs, limit_start, limit_length, rows, end, i = 0;
include_docs = options.include_docs; include_docs = options.include_docs;
options.include_docs = true; options.include_docs = true;
...@@ -627,6 +627,10 @@ ...@@ -627,6 +627,10 @@
return command.storage(priv.sub_storage).allDocs( return command.storage(priv.sub_storage).allDocs(
options options
).then(function (response) { ).then(function (response) {
if (response.data.total_rows === 0) {
end = true;
return [];
}
/*jslint ass: true */ /*jslint ass: true */
var result = [], doc_gids = {}, row, gid; var result = [], doc_gids = {}, row, gid;
response = response.data; response = response.data;
...@@ -657,6 +661,9 @@ ...@@ -657,6 +661,9 @@
doWhile(function () { doWhile(function () {
/*jslint plusplus: true */ /*jslint plusplus: true */
return doAllDocs(i++).then(function () { return doAllDocs(i++).then(function () {
if (end) {
return false;
}
if (limit_length) { if (limit_length) {
if (rows.length < limit_length) { if (rows.length < limit_length) {
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment