Commit c4e7bbde authored by Romain Courteaud's avatar Romain Courteaud

Release version 3.10.0

parent 1cb52dfb
...@@ -6969,11 +6969,12 @@ return new Parser; ...@@ -6969,11 +6969,12 @@ return new Parser;
} }
function checkSignatureDifference(queue, source, destination, id, function checkSignatureDifference(queue, source, destination, id,
conflict_force, conflict_ignore) { conflict_force, conflict_ignore,
getMethod) {
queue queue
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
source.get(id), getMethod(id),
context._signature_sub_storage.get(id) context._signature_sub_storage.get(id)
]); ]);
}) })
...@@ -7021,6 +7022,35 @@ return new Parser; ...@@ -7021,6 +7022,35 @@ return new Parser;
}); });
} }
function checkBulkSignatureDifference(queue, source, destination, id_list,
conflict_force, conflict_ignore) {
queue
.push(function () {
return source.bulk(id_list);
})
.push(function (result_list) {
var i,
sub_queue = new RSVP.Queue();
function getResult(j) {
return function (id) {
if (id !== id_list[j].parameter_list[0]) {
throw new Error("Does not access expected ID " + id);
}
return result_list[j];
};
}
for (i = 0; i < result_list.length; i += 1) {
checkSignatureDifference(sub_queue, source, destination,
id_list[i].parameter_list[0],
conflict_force, conflict_ignore,
getResult(i));
}
return sub_queue;
});
}
function pushStorage(source, destination, options) { function pushStorage(source, destination, options) {
var queue = new RSVP.Queue(); var queue = new RSVP.Queue();
if (!options.hasOwnProperty("use_post")) { if (!options.hasOwnProperty("use_post")) {
...@@ -7037,6 +7067,7 @@ return new Parser; ...@@ -7037,6 +7067,7 @@ return new Parser;
var i, var i,
local_dict = {}, local_dict = {},
new_list = [], new_list = [],
change_list = [],
signature_dict = {}, signature_dict = {},
key; key;
for (i = 0; i < result_list[0].data.total_rows; i += 1) { for (i = 0; i < result_list[0].data.total_rows; i += 1) {
...@@ -7079,9 +7110,17 @@ return new Parser; ...@@ -7079,9 +7110,17 @@ return new Parser;
if (signature_dict.hasOwnProperty(key)) { if (signature_dict.hasOwnProperty(key)) {
if (local_dict.hasOwnProperty(key)) { if (local_dict.hasOwnProperty(key)) {
if (options.check_modification === true) { if (options.check_modification === true) {
checkSignatureDifference(queue, source, destination, key, if (options.use_bulk_get === true) {
options.conflict_force, change_list.push({
options.conflict_ignore); method: "get",
parameter_list: [key]
});
} else {
checkSignatureDifference(queue, source, destination, key,
options.conflict_force,
options.conflict_ignore,
source.get.bind(source));
}
} }
} else { } else {
if (options.check_deletion === true) { if (options.check_deletion === true) {
...@@ -7090,6 +7129,12 @@ return new Parser; ...@@ -7090,6 +7129,12 @@ return new Parser;
} }
} }
} }
if ((options.use_bulk_get === true) && (change_list.length !== 0)) {
checkBulkSignatureDifference(queue, source, destination,
change_list,
options.conflict_force,
options.conflict_ignore);
}
}); });
} }
...@@ -8952,8 +8997,10 @@ return new Parser; ...@@ -8952,8 +8997,10 @@ return new Parser;
}); });
}; };
ERP5Storage.prototype.getAttachment = function (id, action) { ERP5Storage.prototype.getAttachment = function (id, action, options) {
if (options === undefined) {
options = {};
}
if (action === "view") { if (action === "view") {
if (this._default_view_reference === undefined) { if (this._default_view_reference === undefined) {
throw new jIO.util.jIOError( throw new jIO.util.jIOError(
...@@ -8965,7 +9012,6 @@ return new Parser; ...@@ -8965,7 +9012,6 @@ return new Parser;
{"_view": this._default_view_reference}) {"_view": this._default_view_reference})
.push(function (response) { .push(function (response) {
var result = JSON.parse(response.target.responseText); var result = JSON.parse(response.target.responseText);
result._id = id;
result.portal_type = result._links.type.name; result.portal_type = result._links.type.name;
// Remove all ERP5 hateoas links / convert them into jIO ID // Remove all ERP5 hateoas links / convert them into jIO ID
...@@ -8991,21 +9037,47 @@ return new Parser; ...@@ -8991,21 +9037,47 @@ return new Parser;
if (action.indexOf(this._url) === 0) { if (action.indexOf(this._url) === 0) {
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return jIO.util.ajax({ var start,
"type": "GET", end,
"url": action, range,
"xhrFields": { request_options = {
withCredentials: true "type": "GET",
"dataType": "blob",
"url": action,
"xhrFields": {
withCredentials: true
}
};
if (options.start !== undefined || options.end !== undefined) {
start = options.start || 0;
end = options.end;
if (end !== undefined && end < 0) {
throw new jIO.util.jIOError("end must be positive",
400);
}
if (start < 0) {
range = "bytes=" + start;
} else if (end === undefined) {
range = "bytes=" + start + "-";
} else {
if (start > end) {
throw new jIO.util.jIOError("start is greater than end",
400);
}
range = "bytes=" + start + "-" + end;
} }
}); request_options.headers = {Range: range};
}
return jIO.util.ajax(request_options);
}) })
.push(function (evt) { .push(function (evt) {
var result = JSON.parse(evt.target.responseText); if (evt.target.response === undefined) {
result._id = id; return new Blob(
return new Blob( [evt.target.responseText],
[JSON.stringify(result)], {"type": evt.target.getResponseHeader("Content-Type")}
{"type": evt.target.getResponseHeader("Content-Type")} );
); }
return evt.target.response;
}); });
} }
throw new jIO.util.jIOError("ERP5: not support get attachment: " + action, throw new jIO.util.jIOError("ERP5: not support get attachment: " + action,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
{ {
"name": "jio", "name": "jio",
"version": "v3.9.0", "version": "v3.10.0",
"license": "LGPLv3", "license": "LGPLv3",
"author": "Nexedi SA", "author": "Nexedi SA",
"contributors": [ "contributors": [
......
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