Commit 2f903beb authored by Vincent Bechu's avatar Vincent Bechu Committed by Vincent Bechu

replicatestorage: make attachment sync parallel for real

parent b3950a82
...@@ -354,8 +354,8 @@ ...@@ -354,8 +354,8 @@
}); });
} }
function checkAttachmentSignatureDifference(skip_attachment_dict, function checkAttachmentSignatureDifference(queue, skip_attachment_dict,
queue, source, source,
destination, id, name, destination, id, name,
conflict_force, conflict_force,
conflict_revert, conflict_revert,
...@@ -405,8 +405,8 @@ ...@@ -405,8 +405,8 @@
}); });
} }
function checkAttachmentLocalDeletion(skip_attachment_dict, function checkAttachmentLocalDeletion(queue, skip_attachment_dict,
queue, destination, id, name, source, destination, id, name, source,
conflict_force, conflict_revert, conflict_force, conflict_revert,
conflict_ignore) { conflict_ignore) {
var status_hash; var status_hash;
...@@ -427,7 +427,9 @@ ...@@ -427,7 +427,9 @@
function pushDocumentAttachment(skip_attachment_dict, id, source, function pushDocumentAttachment(skip_attachment_dict, id, source,
destination, options) { destination, options) {
var queue = new RSVP.Queue(); var queue = new RSVP.Queue(),
local_dict = {},
signature_dict = {};
return queue return queue
.push(function () { .push(function () {
...@@ -451,11 +453,10 @@ ...@@ -451,11 +453,10 @@
]); ]);
}) })
.push(function (result_list) { .push(function (result_list) {
var local_dict = {}, var is_modification,
signature_dict = {},
is_modification,
is_creation, is_creation,
key; key,
argument_list = [];
for (key in result_list[0]) { for (key in result_list[0]) {
if (result_list[0].hasOwnProperty(key)) { if (result_list[0].hasOwnProperty(key)) {
if (!skip_attachment_dict.hasOwnProperty(key)) { if (!skip_attachment_dict.hasOwnProperty(key)) {
...@@ -478,30 +479,45 @@ ...@@ -478,30 +479,45 @@
is_creation = !signature_dict.hasOwnProperty(key) is_creation = !signature_dict.hasOwnProperty(key)
&& options.check_creation; && options.check_creation;
if (is_modification === true || is_creation === true) { if (is_modification === true || is_creation === true) {
checkAttachmentSignatureDifference(skip_attachment_dict, argument_list.push([undefined,
queue, source, skip_attachment_dict,
destination, id, key, source,
options.conflict_force, destination, id, key,
options.conflict_revert, options.conflict_force,
options.conflict_ignore, options.conflict_revert,
is_creation, options.conflict_ignore,
is_modification); is_creation,
is_modification]);
} }
} }
} }
return dispatchQueue(
checkAttachmentSignatureDifference,
argument_list,
context._parallel_operation_attachment_amount
);
})
.push(function () {
var key, argument_list = [];
if (options.check_deletion === true) { 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)) {
checkAttachmentLocalDeletion(skip_attachment_dict, argument_list.push([undefined,
queue, destination, id, key, skip_attachment_dict,
destination, id, key,
source, source,
options.conflict_force, options.conflict_force,
options.conflict_revert, options.conflict_revert,
options.conflict_ignore); options.conflict_ignore]);
} }
} }
} }
return dispatchQueue(
checkAttachmentLocalDeletion,
argument_list,
context._parallel_operation_attachment_amount
);
} }
}); });
} }
...@@ -1074,7 +1090,7 @@ ...@@ -1074,7 +1090,7 @@
return dispatchQueue( return dispatchQueue(
repairDocument, repairDocument,
argument_list, argument_list,
context._parallel_operation_attachment_amount context._parallel_operation_amount
); );
}); });
} }
......
...@@ -7524,9 +7524,10 @@ ...@@ -7524,9 +7524,10 @@
console.log("get", id); console.log("get", id);
return this._sub_storage.get(id); return this._sub_storage.get(id);
}; };
Storage2713.prototype.getAttachment = function (id) { Storage2713.prototype.getAttachment = function () {
var storage = this, var storage = this,
argument_list = arguments; argument_list = arguments,
id = argument_list[1];
start_sync[id] = true; start_sync[id] = true;
return ((id === "0") ? RSVP.delay(500) : RSVP.delay(100)) return ((id === "0") ? RSVP.delay(500) : RSVP.delay(100))
.then(function () { .then(function () {
...@@ -7586,27 +7587,18 @@ ...@@ -7586,27 +7587,18 @@
} }
}); });
return context.jio.put("0", {"title": "foo"}) return context.jio.put("foo", {})
.push(function () {
return context.jio.putAttachment("0", "foo", new Blob(["0"]));
})
.push(function () {
return context.jio.put("1", {"title": "foo1"});
})
.push(function () { .push(function () {
return context.jio.putAttachment("1", "foo", new Blob(["1"])); return context.jio.putAttachment("foo", "0", new Blob(["0"]));
}) })
.push(function () { .push(function () {
return context.jio.put("2", {"title": "foo2"}); return context.jio.putAttachment("foo", "1", new Blob(["1"]));
}) })
.push(function () { .push(function () {
return context.jio.putAttachment("2", "foo", new Blob(["2"])); return context.jio.putAttachment("foo", "2", new Blob(["2"]));
})
.push(function () {
return context.jio.put("3", {"title": "foo3"});
}) })
.push(function () { .push(function () {
return context.jio.putAttachment("3", "foo", new Blob(["3"])); return context.jio.putAttachment("foo", "3", new Blob(["3"]));
}) })
.push(function () { .push(function () {
return context.jio.repair(); return context.jio.repair();
......
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