Commit 6a62e0bb authored by Sven Franck's avatar Sven Franck

updated to latest JIO

parent f282631d
...@@ -436,6 +436,23 @@ defaults.job_rule_conditions = {}; ...@@ -436,6 +436,23 @@ defaults.job_rule_conditions = {};
return a.kwargs._id === b.kwargs._id; return a.kwargs._id === b.kwargs._id;
} }
/**
* Test if the jobs have a document id.
*
* @param {Object} a The first job to test
* @param {Object} b The second job to test
* @return {Boolean} True if ids exist, else false
*/
function haveDocumentIds(a, b) {
if (typeof a.kwargs._id !== "string" || a.kwargs._id === "") {
return false;
}
if (typeof b.kwargs._id !== "string" || b.kwargs._id === "") {
return false;
}
return true;
}
/** /**
* Compare two jobs and test if their kwargs are equal * Compare two jobs and test if their kwargs are equal
* *
...@@ -467,7 +484,8 @@ defaults.job_rule_conditions = {}; ...@@ -467,7 +484,8 @@ defaults.job_rule_conditions = {};
"sameMethod": sameMethod, "sameMethod": sameMethod,
"sameDocumentId": sameDocumentId, "sameDocumentId": sameDocumentId,
"sameParameters": sameParameters, "sameParameters": sameParameters,
"sameOptions": sameOptions "sameOptions": sameOptions,
"haveDocumentIds": haveDocumentIds
}; };
}()); }());
...@@ -1595,8 +1613,8 @@ LocalStorageArray.saveArray = function (namespace, list) { ...@@ -1595,8 +1613,8 @@ LocalStorageArray.saveArray = function (namespace, list) {
*/ */
function Metadata(metadata) { function Metadata(metadata) {
if (arguments.length > 0) { if (arguments.length > 0) {
if (typeof metadata !== 'object' || if (metadata === null || typeof metadata !== 'object' ||
Object.getPrototypeOf(metadata || []) !== Object.prototype) { Array.isArray(metadata)) {
throw new TypeError("Metadata(): Optional argument 1 is not an object"); throw new TypeError("Metadata(): Optional argument 1 is not an object");
} }
this._dict = metadata; this._dict = metadata;
...@@ -2171,6 +2189,10 @@ function restCommandRejecter(param, args) { ...@@ -2171,6 +2189,10 @@ function restCommandRejecter(param, args) {
if (typeof a === 'object' && !Array.isArray(a)) { if (typeof a === 'object' && !Array.isArray(a)) {
dictUpdate(weak, a); dictUpdate(weak, a);
if (a instanceof Error) {
weak.reason = a.message;
weak.error = a.name;
}
} }
dictUpdate(weak, strong); dictUpdate(weak, strong);
...@@ -2481,6 +2503,7 @@ function enableJobChecker(jio, shared, options) { ...@@ -2481,6 +2503,7 @@ function enableJobChecker(jio, shared, options) {
"sameStorageDescription", "sameStorageDescription",
"areWriters", "areWriters",
"sameMethod", "sameMethod",
"haveDocumentIds",
"sameParameters" "sameParameters"
], ],
"action": "update" "action": "update"
...@@ -2489,6 +2512,7 @@ function enableJobChecker(jio, shared, options) { ...@@ -2489,6 +2512,7 @@ function enableJobChecker(jio, shared, options) {
"conditions": [ "conditions": [
"sameStorageDescription", "sameStorageDescription",
"areWriters", "areWriters",
"haveDocumentIds",
"sameDocumentId" "sameDocumentId"
], ],
"action": "wait" "action": "wait"
...@@ -2798,7 +2822,7 @@ function enableJobRecovery(jio, shared, options) { ...@@ -2798,7 +2822,7 @@ function enableJobRecovery(jio, shared, options) {
var job; var job;
shared.job_queue.load(); shared.job_queue.load();
job = shared.job_queue.get(id); job = shared.job_queue.get(id);
if (job.modified === modified) { if (job && job.modified === modified) {
// job not modified, no one takes care of it // job not modified, no one takes care of it
recoverJob(job); recoverJob(job);
} }
......
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