Commit 6f04463d authored by Romain Courteaud's avatar Romain Courteaud

ReplicateStorage: correctly skip attachment

parent 425f7194
...@@ -299,7 +299,7 @@ ...@@ -299,7 +299,7 @@
}); });
} }
function checkAndPropagateAttachment(context, skip_document_dict, function checkAndPropagateAttachment(context,
skip_attachment_dict, skip_attachment_dict,
status_hash, local_hash, blob, status_hash, local_hash, blob,
source, destination, id, name, source, destination, id, name,
...@@ -330,7 +330,7 @@ ...@@ -330,7 +330,7 @@
// Deleted on both side, drop signature // Deleted on both side, drop signature
return context._signature_sub_storage.removeAttachment(id, name) return context._signature_sub_storage.removeAttachment(id, name)
.push(function () { .push(function () {
skip_attachment_dict[id] = null; skip_attachment_dict[name] = null;
}); });
} }
...@@ -339,7 +339,7 @@ ...@@ -339,7 +339,7 @@
hash: local_hash hash: local_hash
})) }))
.push(function () { .push(function () {
skip_document_dict[id] = null; skip_attachment_dict[name] = null;
}); });
} }
...@@ -396,7 +396,6 @@ ...@@ -396,7 +396,6 @@
} }
function checkAttachmentSignatureDifference(queue, context, function checkAttachmentSignatureDifference(queue, context,
skip_document_dict,
skip_attachment_dict, skip_attachment_dict,
source, source,
destination, id, name, destination, id, name,
...@@ -439,7 +438,7 @@ ...@@ -439,7 +438,7 @@
local_hash = generateHashFromArrayBuffer(array_buffer); local_hash = generateHashFromArrayBuffer(array_buffer);
if (local_hash !== status_hash) { if (local_hash !== status_hash) {
return checkAndPropagateAttachment(context, skip_document_dict, return checkAndPropagateAttachment(context,
skip_attachment_dict, skip_attachment_dict,
status_hash, local_hash, blob, status_hash, local_hash, blob,
source, destination, id, name, source, destination, id, name,
...@@ -449,7 +448,7 @@ ...@@ -449,7 +448,7 @@
}); });
} }
function checkAttachmentLocalDeletion(queue, context, skip_document_dict, function checkAttachmentLocalDeletion(queue, context,
skip_attachment_dict, skip_attachment_dict,
destination, id, name, source, destination, id, name, source,
conflict_force, conflict_revert, conflict_force, conflict_revert,
...@@ -462,7 +461,7 @@ ...@@ -462,7 +461,7 @@
}) })
.push(function (result) { .push(function (result) {
status_hash = result.hash; status_hash = result.hash;
return checkAndPropagateAttachment(context, skip_document_dict, return checkAndPropagateAttachment(context,
skip_attachment_dict, skip_attachment_dict,
status_hash, null, null, status_hash, null, null,
source, destination, id, name, source, destination, id, name,
...@@ -471,9 +470,10 @@ ...@@ -471,9 +470,10 @@
}); });
} }
function pushDocumentAttachment(context, skip_document_dict, function pushDocumentAttachment(context,
skip_attachment_dict, id, source, skip_attachment_dict, id, source,
destination, options) { destination,
options) {
var queue = new RSVP.Queue(), var queue = new RSVP.Queue(),
local_dict = {}, local_dict = {},
signature_dict = {}; signature_dict = {};
...@@ -527,7 +527,6 @@ ...@@ -527,7 +527,6 @@
if (is_modification === true || is_creation === true) { if (is_modification === true || is_creation === true) {
argument_list.push([undefined, argument_list.push([undefined,
context, context,
skip_document_dict,
skip_attachment_dict, skip_attachment_dict,
source, source,
destination, id, key, destination, id, key,
...@@ -554,7 +553,6 @@ ...@@ -554,7 +553,6 @@
if (!local_dict.hasOwnProperty(key)) { if (!local_dict.hasOwnProperty(key)) {
argument_list.push([undefined, argument_list.push([undefined,
context, context,
skip_document_dict,
skip_attachment_dict, skip_attachment_dict,
destination, id, key, destination, id, key,
source, source,
...@@ -574,7 +572,7 @@ ...@@ -574,7 +572,7 @@
}); });
} }
function repairDocumentAttachment(context, id, skip_document_dict) { function repairDocumentAttachment(context, id) {
var skip_attachment_dict = {}; var skip_attachment_dict = {};
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
...@@ -583,7 +581,6 @@ ...@@ -583,7 +581,6 @@
context._check_local_attachment_deletion) { context._check_local_attachment_deletion) {
return pushDocumentAttachment( return pushDocumentAttachment(
context, context,
skip_document_dict,
skip_attachment_dict, skip_attachment_dict,
id, id,
context._local_sub_storage, context._local_sub_storage,
...@@ -609,7 +606,6 @@ ...@@ -609,7 +606,6 @@
context._check_remote_attachment_deletion) { context._check_remote_attachment_deletion) {
return pushDocumentAttachment( return pushDocumentAttachment(
context, context,
skip_document_dict,
skip_attachment_dict, skip_attachment_dict,
id, id,
context._remote_sub_storage, context._remote_sub_storage,
...@@ -738,7 +734,7 @@ ...@@ -738,7 +734,7 @@
// ie, replication should prevent losing user data // ie, replication should prevent losing user data
// Synchronize attachments before, to ensure // Synchronize attachments before, to ensure
// all of them will be deleted too // all of them will be deleted too
return repairDocumentAttachment(context, id, skip_document_dict) return repairDocumentAttachment(context, id)
.push(function () { .push(function () {
return destination.allAttachments(id); return destination.allAttachments(id);
}) })
...@@ -1046,9 +1042,9 @@ ...@@ -1046,9 +1042,9 @@
}); });
} }
function repairDocument(queue, context, id, skip_document_dict) { function repairDocument(queue, context, id) {
queue.push(function () { queue.push(function () {
return repairDocumentAttachment(context, id, skip_document_dict); return repairDocumentAttachment(context, id);
}); });
} }
...@@ -1184,8 +1180,7 @@ ...@@ -1184,8 +1180,7 @@
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
local_argument_list.push( local_argument_list.push(
[undefined, context, result.data.rows[i].id, [undefined, context, result.data.rows[i].id]
skip_document_dict]
); );
} }
return dispatchQueue( return dispatchQueue(
......
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