Commit db73ae15 authored by Romain Courteaud's avatar Romain Courteaud

ReplicateStorage: remove one useless signature_storage.allDocs call

parent cb2db8ac
...@@ -860,9 +860,8 @@ ...@@ -860,9 +860,8 @@
}); });
} }
function pushStorage(source, destination, options) { function pushStorage(source, destination, signature_allDocs, options) {
var queue = new RSVP.Queue(), var argument_list = [],
argument_list = [],
argument_list_deletion = []; argument_list_deletion = [];
if (!options.hasOwnProperty("use_post")) { if (!options.hasOwnProperty("use_post")) {
options.use_post = false; options.use_post = false;
...@@ -870,14 +869,8 @@ ...@@ -870,14 +869,8 @@
if (!options.hasOwnProperty("use_revert_post")) { if (!options.hasOwnProperty("use_revert_post")) {
options.use_revert_post = false; options.use_revert_post = false;
} }
return queue return source.allDocs(context._query_options)
.push(function () { .push(function (source_allDocs) {
return RSVP.all([
source.allDocs(context._query_options),
context._signature_sub_storage.allDocs()
]);
})
.push(function (result_list) {
var i, var i,
local_dict = {}, local_dict = {},
document_list = [], document_list = [],
...@@ -885,19 +878,20 @@ ...@@ -885,19 +878,20 @@
signature_dict = {}, signature_dict = {},
is_modification, is_modification,
is_creation, is_creation,
key; key,
for (i = 0; i < result_list[0].data.total_rows; i += 1) { queue = new RSVP.Queue();
for (i = 0; i < source_allDocs.data.total_rows; i += 1) {
if (!skip_document_dict.hasOwnProperty( if (!skip_document_dict.hasOwnProperty(
result_list[0].data.rows[i].id source_allDocs.data.rows[i].id
)) { )) {
local_dict[result_list[0].data.rows[i].id] = i; local_dict[source_allDocs.data.rows[i].id] = i;
} }
} }
for (i = 0; i < result_list[1].data.total_rows; i += 1) { for (i = 0; i < signature_allDocs.data.total_rows; i += 1) {
if (!skip_document_dict.hasOwnProperty( if (!skip_document_dict.hasOwnProperty(
result_list[1].data.rows[i].id signature_allDocs.data.rows[i].id
)) { )) {
signature_dict[result_list[1].data.rows[i].id] = i; signature_dict[signature_allDocs.data.rows[i].id] = i;
} }
} }
i = 0; i = 0;
...@@ -971,6 +965,7 @@ ...@@ -971,6 +965,7 @@
options.conflict_revert, options.conflict_revert,
options.conflict_ignore); options.conflict_ignore);
} }
return queue;
}); });
} }
...@@ -1017,11 +1012,23 @@ ...@@ -1017,11 +1012,23 @@
}) })
.push(function () { .push(function () {
if (context._check_local_modification ||
context._check_local_creation ||
context._check_local_deletion ||
context._check_remote_modification ||
context._check_remote_creation ||
context._check_remote_deletion) {
return context._signature_sub_storage.allDocs();
}
})
.push(function (signature_allDocs) {
if (context._check_local_modification || if (context._check_local_modification ||
context._check_local_creation || context._check_local_creation ||
context._check_local_deletion) { context._check_local_deletion) {
return pushStorage(context._local_sub_storage, return pushStorage(context._local_sub_storage,
context._remote_sub_storage, context._remote_sub_storage,
signature_allDocs,
{ {
use_post: context._use_remote_post, use_post: context._use_remote_post,
conflict_force: (context._conflict_handling === conflict_force: (context._conflict_handling ===
...@@ -1034,10 +1041,14 @@ ...@@ -1034,10 +1041,14 @@
check_creation: context._check_local_creation, check_creation: context._check_local_creation,
check_deletion: context._check_local_deletion, check_deletion: context._check_local_deletion,
operation_amount: context._parallel_operation_amount operation_amount: context._parallel_operation_amount
})
.push(function () {
return signature_allDocs;
}); });
} }
return signature_allDocs;
}) })
.push(function () { .push(function (signature_allDocs) {
// Autoactivate bulk if substorage implements it // Autoactivate bulk if substorage implements it
// Keep it like this until the bulk API is stabilized // Keep it like this until the bulk API is stabilized
var use_bulk_get = false; var use_bulk_get = false;
...@@ -1053,7 +1064,8 @@ ...@@ -1053,7 +1064,8 @@
context._check_remote_creation || context._check_remote_creation ||
context._check_remote_deletion) { context._check_remote_deletion) {
return pushStorage(context._remote_sub_storage, return pushStorage(context._remote_sub_storage,
context._local_sub_storage, { context._local_sub_storage,
signature_allDocs, {
use_bulk_get: use_bulk_get, use_bulk_get: use_bulk_get,
use_revert_post: context._use_remote_post, use_revert_post: context._use_remote_post,
conflict_force: (context._conflict_handling === conflict_force: (context._conflict_handling ===
......
...@@ -3874,7 +3874,7 @@ ...@@ -3874,7 +3874,7 @@
test("substorages are repaired too", function () { test("substorages are repaired too", function () {
stop(); stop();
expect(9); expect(8);
var context = this, var context = this,
first_call = true, first_call = true,
...@@ -3943,7 +3943,7 @@ ...@@ -3943,7 +3943,7 @@
test("sync all documents by default", function () { test("sync all documents by default", function () {
stop(); stop();
expect(5); expect(4);
var context = this; var context = this;
...@@ -3991,7 +3991,7 @@ ...@@ -3991,7 +3991,7 @@
test("sync can be restricted to some documents", function () { test("sync can be restricted to some documents", function () {
stop(); stop();
expect(5); expect(4);
var context = this, var context = this,
query = {query: 'portal_type: "Foo"', limit: [0, 1234567890]}; query = {query: 'portal_type: "Foo"', limit: [0, 1234567890]};
......
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