Support add/remove objects from presets and tasks

This commit is contained in:
Zaid Abdulla committed 2016-12-29 13:04:11 -08:00
1 parent 179211ce53
commit 33b01d68ca
3 files changed
+113 -58

No files matched your search

+26
View File
@@ -18,6 +18,7 @@
const config = require("./config");
const common = require("./common");
const device = require("./device");
const MAX_DEPTH = config.get("MAX_DEPTH");
@@ -79,9 +80,34 @@ function download(sessionData, provision, declarations, startRevision, endRevisi
}
function instances(sessionData, provision, declarations, startRevision, endRevision) {
let count = Number(provision[2]);
if (Number.isNaN(count))
return true;
let path = common.parsePath(provision[1]);
if (provision[2][0] === "+" || provision[2][0] === "-") {
declarations.push([path, 1]);
if (endRevision === startRevision)
return false;
let unpacked = device.unpack(sessionData.deviceData, path, startRevision + 1);
count = Math.max(0, unpacked.length + count);
}
declarations.push([path, 1, null, count]);
return true;
}
exports.refresh = refresh;
exports.value = value;
exports.tag = tag;
exports.reboot = reboot;
exports.reset = reset;
exports.download = download;
exports.instances = instances;