Commit acb3274d authored by Romain Courteaud's avatar Romain Courteaud

ReplicateStorage: skip attachment replication if document deletion is skipped

If the document was deleted, user does not want probably to see it reappear identical.
parent cb2eaea6
...@@ -928,6 +928,7 @@ ...@@ -928,6 +928,7 @@
} }
function pushStorage(context, skip_document_dict, function pushStorage(context, skip_document_dict,
skip_deleted_document_dict,
cache, source_key, destination_key, cache, source_key, destination_key,
source, destination, signature_allDocs, options) { source, destination, signature_allDocs, options) {
var argument_list = [], var argument_list = [],
...@@ -1022,10 +1023,10 @@ ...@@ -1022,10 +1023,10 @@
options.operation_amount options.operation_amount
); );
}); });
if (options.check_deletion === true) { for (key in signature_dict) {
for (key in signature_dict) { if (signature_dict.hasOwnProperty(key)) {
if (signature_dict.hasOwnProperty(key)) { if (!local_dict.hasOwnProperty(key)) {
if (!local_dict.hasOwnProperty(key)) { if (options.check_deletion === true) {
argument_list_deletion.push([undefined, argument_list_deletion.push([undefined,
context, context,
skip_document_dict, skip_document_dict,
...@@ -1036,9 +1037,13 @@ ...@@ -1036,9 +1037,13 @@
options.conflict_revert, options.conflict_revert,
options.conflict_ignore, options.conflict_ignore,
options]); options]);
} else {
skip_deleted_document_dict[key] = null;
} }
} }
} }
}
if (argument_list_deletion.length !== 0) {
queue.push(function () { queue.push(function () {
return dispatchQueue( return dispatchQueue(
context, context,
...@@ -1062,6 +1067,7 @@ ...@@ -1062,6 +1067,7 @@
var context = this, var context = this,
argument_list = arguments, argument_list = arguments,
skip_document_dict = {}, skip_document_dict = {},
skip_deleted_document_dict = {},
cache = {}; cache = {};
return new RSVP.Queue() return new RSVP.Queue()
...@@ -1125,6 +1131,7 @@ ...@@ -1125,6 +1131,7 @@
context._check_local_creation || context._check_local_creation ||
context._check_local_deletion) { context._check_local_deletion) {
return pushStorage(context, skip_document_dict, return pushStorage(context, skip_document_dict,
skip_deleted_document_dict,
cache, 'local', 'remote', cache, 'local', 'remote',
context._local_sub_storage, context._local_sub_storage,
context._remote_sub_storage, context._remote_sub_storage,
...@@ -1154,6 +1161,7 @@ ...@@ -1154,6 +1161,7 @@
context._check_remote_creation || context._check_remote_creation ||
context._check_remote_deletion) { context._check_remote_deletion) {
return pushStorage(context, skip_document_dict, return pushStorage(context, skip_document_dict,
skip_deleted_document_dict,
cache, 'remote', 'local', cache, 'remote', 'local',
context._remote_sub_storage, context._remote_sub_storage,
context._local_sub_storage, context._local_sub_storage,
...@@ -1186,12 +1194,19 @@ ...@@ -1186,12 +1194,19 @@
.push(function (result) { .push(function (result) {
var i, var i,
local_argument_list = [], local_argument_list = [],
id,
len = result.data.total_rows; len = result.data.total_rows;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
local_argument_list.push( id = result.data.rows[i].id;
[undefined, context, result.data.rows[i].id] // Do not synchronize attachment if one version of the document
); // is deleted but not pushed to the other storage
if (!skip_deleted_document_dict.hasOwnProperty(id) ||
skip_document_dict.hasOwnProperty(id)) {
local_argument_list.push(
[undefined, context, id]
);
}
} }
return dispatchQueue( return dispatchQueue(
context, context,
......
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