configure/restoreInstalledApps must always succeed
This commit is contained in:
@@ -345,7 +345,7 @@ function setInstallationCommand(appId, installationState, values, callback) {
|
|||||||
updateWithConstraints(appId, values, '', callback);
|
updateWithConstraints(appId, values, '', callback);
|
||||||
} else if (installationState === exports.ISTATE_PENDING_RESTORE) {
|
} else if (installationState === exports.ISTATE_PENDING_RESTORE) {
|
||||||
updateWithConstraints(appId, values, 'AND (installationState = "installed" OR installationState = "error")', callback);
|
updateWithConstraints(appId, values, 'AND (installationState = "installed" OR installationState = "error")', callback);
|
||||||
} else if (installationState === exports.ISTATE_PENDING_UPDATE || installationState === exports.ISTATE_PENDING_BACKUP) {
|
} else if (installationState === exports.ISTATE_PENDING_UPDATE || installationState === exports.ISTATE_PENDING_BACKUP || installationState === exports.ISTATE_PENDING_CONFIGURE) {
|
||||||
updateWithConstraints(appId, values, 'AND installationState = "installed"', callback);
|
updateWithConstraints(appId, values, 'AND installationState = "installed"', callback);
|
||||||
} else if (installationState === exports.ISTATE_PENDING_CONFIGURE) {
|
} else if (installationState === exports.ISTATE_PENDING_CONFIGURE) {
|
||||||
updateWithConstraints(appId, values, 'AND installationState = "installed" OR installationState = "pending_configure" OR installationState = "error"', callback);
|
updateWithConstraints(appId, values, 'AND installationState = "installed" OR installationState = "pending_configure" OR installationState = "error"', callback);
|
||||||
|
|||||||
16
src/apps.js
16
src/apps.js
@@ -931,11 +931,13 @@ function restoreInstalledApps(callback) {
|
|||||||
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
|
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
|
||||||
|
|
||||||
async.map(apps, function (app, iteratorDone) {
|
async.map(apps, function (app, iteratorDone) {
|
||||||
if (app.installationState !== appdb.ISTATE_INSTALLED) return iteratorDone();
|
|
||||||
|
|
||||||
debug('marking %s for restore', app.location || app.id);
|
debug('marking %s for restore', app.location || app.id);
|
||||||
|
|
||||||
appdb.setInstallationCommand(app.id, appdb.ISTATE_PENDING_RESTORE, { oldConfig: null }, iteratorDone);
|
appdb.setInstallationCommand(app.id, appdb.ISTATE_PENDING_RESTORE, { oldConfig: null }, function (error) {
|
||||||
|
if (error) debug('did not mark %s for restore', app.location || app.id, error);
|
||||||
|
|
||||||
|
iteratorDone(); // always succeed
|
||||||
|
});
|
||||||
}, callback);
|
}, callback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -947,11 +949,13 @@ function configureInstalledApps(callback) {
|
|||||||
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
|
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
|
||||||
|
|
||||||
async.map(apps, function (app, iteratorDone) {
|
async.map(apps, function (app, iteratorDone) {
|
||||||
if (app.installationState !== appdb.ISTATE_INSTALLED) return iteratorDone();
|
|
||||||
|
|
||||||
debug('marking %s for reconfigure', app.location || app.id);
|
debug('marking %s for reconfigure', app.location || app.id);
|
||||||
|
|
||||||
appdb.setInstallationCommand(app.id, appdb.ISTATE_PENDING_CONFIGURE, { oldConfig: null }, iteratorDone);
|
appdb.setInstallationCommand(app.id, appdb.ISTATE_PENDING_CONFIGURE, { oldConfig: null }, function (error) {
|
||||||
|
if (error) debug('did not mark %s for reconfigure', app.location || app.id, error);
|
||||||
|
|
||||||
|
iteratorDone(); // always succeed
|
||||||
|
});
|
||||||
}, callback);
|
}, callback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ describe('Apps', function () {
|
|||||||
apps.getAll(function (error, apps) {
|
apps.getAll(function (error, apps) {
|
||||||
expect(apps[0].installationState).to.be(appdb.ISTATE_PENDING_RESTORE);
|
expect(apps[0].installationState).to.be(appdb.ISTATE_PENDING_RESTORE);
|
||||||
expect(apps[0].oldConfig).to.be(null);
|
expect(apps[0].oldConfig).to.be(null);
|
||||||
expect(apps[1].installationState).to.be(appdb.ISTATE_ERROR);
|
expect(apps[1].installationState).to.be(appdb.ISTATE_PENDING_RESTORE);
|
||||||
expect(apps[2].installationState).to.be(appdb.ISTATE_PENDING_RESTORE);
|
expect(apps[2].installationState).to.be(appdb.ISTATE_PENDING_RESTORE);
|
||||||
expect(apps[2].oldConfig).to.be(null);
|
expect(apps[2].oldConfig).to.be(null);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user