stop previous task explicitly
there is a race: 1. task is running 2. new task is created overwriting the installationState 3. new task kills the old task of step 1. this results in installationState getting overwritten by 'error' because of the sigkill 4. new task that is launched loses the installationState that was step in 2.
This commit is contained in:
12
src/apps.js
12
src/apps.js
@@ -578,13 +578,15 @@ function uninstall(appId, callback) {
|
||||
|
||||
debug('Will uninstall app with id:%s', appId);
|
||||
|
||||
appdb.setInstallationCommand(appId, appdb.ISTATE_PENDING_UNINSTALL, function (error) {
|
||||
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new AppsError(AppsError.NOT_FOUND, 'No such app'));
|
||||
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
|
||||
taskmanager.stopAppTask(appId, function () {
|
||||
appdb.setInstallationCommand(appId, appdb.ISTATE_PENDING_UNINSTALL, function (error) {
|
||||
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new AppsError(AppsError.NOT_FOUND, 'No such app'));
|
||||
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
|
||||
|
||||
taskmanager.restartAppTask(appId); // since uninstall is allowed from any state, kill current task
|
||||
taskmanager.startAppTask(appId); // since uninstall is allowed from any state, kill current task
|
||||
|
||||
callback(null);
|
||||
callback(null);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user