Use taskId instead of states to check bad state

a) this is because, we have install state and run state.
b) we have to put taskId as part of the transaction to prevent race
This commit is contained in:
Girish Ramakrishnan
2019-08-29 12:14:42 -07:00
parent ed57260fcf
commit 9cf833dab2
2 changed files with 64 additions and 106 deletions
+3 -17
View File
@@ -21,8 +21,7 @@ exports = module.exports = {
getAppIdByAddonConfigValue: getAppIdByAddonConfigValue,
setHealth: setHealth,
setInstallationCommand: setInstallationCommand,
setRunCommand: setRunCommand,
setTask: setTask,
getAppStoreIds: getAppStoreIds,
// installation codes (keep in sync in UI)
@@ -479,25 +478,12 @@ function setHealth(appId, health, healthTime, callback) {
updateWithConstraints(appId, values, constraints, callback);
}
function setInstallationCommand(appId, installationState, values, callback) {
function setTask(appId, values, callback) {
assert.strictEqual(typeof appId, 'string');
assert.strictEqual(typeof installationState, 'string');
assert.strictEqual(typeof values, 'object');
assert.strictEqual(typeof callback, 'function');
values.installationState = installationState;
values.errorMessage = '';
updateWithConstraints(appId, values, `AND (installationState = "${exports.ISTATE_INSTALLED}" OR installationState = "${exports.ISTATE_ERROR}")`, callback);
}
function setRunCommand(appId, runState, callback) {
assert.strictEqual(typeof appId, 'string');
assert.strictEqual(typeof runState, 'string');
assert.strictEqual(typeof callback, 'function');
var values = { runState: runState };
updateWithConstraints(appId, values, `AND installationState = "${exports.ISTATE_INSTALLED}"`, callback);
updateWithConstraints(appId, values, 'AND taskId IS NULL', callback);
}
function getAppStoreIds(callback) {