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:
+3
-17
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user