From 50c4e4c91e5bf1e6cedb37df31550a0d519b0e80 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 2 Jun 2016 19:26:42 -0700 Subject: [PATCH] log event only after lock is acquired --- src/cloudron.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cloudron.js b/src/cloudron.js index dfeafd2d3..8583a6d53 100644 --- a/src/cloudron.js +++ b/src/cloudron.js @@ -495,8 +495,9 @@ function reboot(callback) { shell.sudo('reboot', [ REBOOT_CMD ], callback); } -function update(boxUpdateInfo, callback) { +function update(boxUpdateInfo, auditSource, callback) { assert.strictEqual(typeof boxUpdateInfo, 'object'); + assert.strictEqual(typeof auditSource, 'object'); assert.strictEqual(typeof callback, 'function'); if (!boxUpdateInfo) return callback(null); @@ -504,6 +505,8 @@ function update(boxUpdateInfo, callback) { var error = locker.lock(locker.OP_BOX_UPDATE); if (error) return callback(new CloudronError(CloudronError.BAD_STATE, error.message)); + eventlog.add(eventlog.ACTION_UPDATE, auditSource, { boxUpdateInfo: boxUpdateInfo }); + // ensure tools can 'wait' on progress progress.set(progress.UPDATE, 0, 'Starting'); @@ -542,9 +545,7 @@ function updateToLatest(auditSource, callback) { var boxUpdateInfo = updateChecker.getUpdateInfo().box; if (!boxUpdateInfo) return callback(new CloudronError(CloudronError.ALREADY_UPTODATE, 'No update available')); - eventlog.add(eventlog.ACTION_UPDATE, auditSource, { boxUpdateInfo: boxUpdateInfo }); - - update(boxUpdateInfo, callback); + update(boxUpdateInfo, auditSource, callback); } function doShortCircuitUpdate(boxUpdateInfo, callback) {