Commit 2d5a5f89 authored by Sven Franck's avatar Sven Franck

fixed timeout because of errors not being caught in sequence

parent 24b9e1e7
......@@ -51,14 +51,16 @@
* @return {Object} clones object
*/
function cleanClone (obj) {
// NOTE: polyfill needed for IE8-
var r = Object.create(obj);
if (r._missing) {
delete r._missing;
}
if (r._conflict_list) {
delete r._conflict_list;
var prop, r = {};
for (prop in obj) {
if (obj.hasOwnProperty(prop)) {
if (prop.charCodeAt(0) !== 95 || prop === "_id") {
r[prop] = obj[prop];
}
}
}
return r;
};
......@@ -242,14 +244,14 @@
promise_list = promise_list.slice();
return new Promise(function (resolve, reject, notify) {
var index, doc, trace, version_list, count, error_count, tag;
var index, trace, conflict_list, count, error_count, tag, doc;
version_list = [];
count = 0;
error_count = 0;
conflict_list = [];
tag = function (reply) {
if (version_list.length) {
reply._conflict_list = version_list;
if (conflict_list.length) {
reply._conflict_list = conflict_list;
}
if (error_count) {
reply._missing = true;
......@@ -259,19 +261,16 @@
function resolver(answer) {
if (trace === undefined) {
trace = checksum(answer);
doc = answer;
trace = checksum(cleanClone(answer.data));
} else {
if (trace !== checksum(answer)) {
if (version.list.length === 0) {
version_list.push(doc);
}
version_list.push(answer);
if (trace !== checksum(cleanClone(answer.data))) {
conflict_list.push(cleanClone(answer.data));
}
}
count += 1;
if (count === length) {
return resolve(tag(doc));
return resolve(tag(answer));
}
}
function rejecter(answer) {
......@@ -292,7 +291,6 @@
});
};
}
for (index = 0; index < length; index += 1) {
promise_list[index].then(resolver, rejecter, notifier(index));
}
......
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