Only install app if state is PENDING_INSTALL

This commit is contained in:
Johannes Zellner
2014-08-25 09:28:43 -07:00
parent 6a3350a54c
commit 98a91c2b4f
+11 -5
View File
@@ -645,7 +645,7 @@ function startTask(appId, callback) {
if (app.runState === appdb.RSTATE_PENDING_STOP) {
stopApp(app, callback);
} else if (app.runState === appdb.RSTATE_PENDING_START || app.runState === appdb.RSTART_RUNNING) {
console.log('Resuming app with state : %s %s', app.runState, app.id);
debug('Resuming app with state : %s %s', app.runState, app.id);
runApp(app, callback);
} else {
callback(null);
@@ -654,11 +654,17 @@ function startTask(appId, callback) {
return;
}
install(app, function (error) {
if (error) return callback(error);
if (app.installationState === appdb.ISTATE_PENDING_INSTALL) {
install(app, function (error) {
if (error) return callback(error);
runApp(app, callback);
});
runApp(app, callback);
});
return;
}
console.error('Apptask launched but nothing to do.', app);
return callback(null);
});
}