make cloudron.updateToLatest take an auditSource

This commit is contained in:
Girish Ramakrishnan
2016-05-01 13:15:30 -07:00
parent d811115f21
commit 8254337552
4 changed files with 16 additions and 7 deletions

View File

@@ -19,7 +19,8 @@ function backup(req, res, next) {
// note that cloudron.backup only waits for backup initiation and not for backup to complete
// backup progress can be checked up ny polling the progress api call
backups.backup({ userId: null, username: 'sysadmin' }, function (error) {
var auditSource = { userId: null, username: 'sysadmin' };
backups.backup(auditSource, function (error) {
if (error && error.reason === BackupsError.BAD_STATE) return next(new HttpError(409, error.message));
if (error) return next(new HttpError(500, error));
@@ -31,7 +32,8 @@ function update(req, res, next) {
debug('triggering update');
// this only initiates the update, progress can be checked via the progress route
cloudron.updateToLatest(function (error) {
var auditSource = { userId: null, username: 'sysadmin' };
cloudron.updateToLatest(auditSource, function (error) {
if (error && error.reason === CloudronError.ALREADY_UPTODATE) return next(new HttpError(422, error.message));
if (error && error.reason === CloudronError.BAD_STATE) return next(new HttpError(409, error.message));
if (error) return next(new HttpError(500, error));