From cb51f44a4585cd6cb335bbe80ef559045c3af505 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Tue, 18 Feb 2020 15:28:55 +0100 Subject: [PATCH] fix(xo-web/xoa-updater): handle all `*-upgrade-needed` states Otherwise adding new namespaces in the updater will break state handling. --- packages/xo-web/src/common/xoa-updater.js | 34 +++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/xo-web/src/common/xoa-updater.js b/packages/xo-web/src/common/xoa-updater.js index 5e0aa5058..fb4f14b2f 100644 --- a/packages/xo-web/src/common/xoa-updater.js +++ b/packages/xo-web/src/common/xoa-updater.js @@ -126,23 +126,23 @@ class XoaUpdater extends EventEmitter { }) middle.on('end', end => { this._lowState = end - switch (this._lowState.state) { - case 'xoa-up-to-date': - case 'xoa-upgraded': - case 'updater-upgraded': - case 'installer-upgraded': - this.state('upToDate') - break - case 'xoa-upgrade-needed': - case 'updater-upgrade-needed': - case 'installer-upgrade-needed': - this.state('upgradeNeeded') - break - case 'register-needed': - this.state('registerNeeded') - break - default: - this.state('error') + const { state } = end + if (state.endsWith('-upgrade-needed')) { + this.state('upgradeNeeded') + } else { + switch (this._lowState.state) { + case 'xoa-up-to-date': + case 'xoa-upgraded': + case 'updater-upgraded': + case 'installer-upgraded': + this.state('upToDate') + break + case 'register-needed': + this.state('registerNeeded') + break + default: + this.state('error') + } } this.log(end.level, end.message) this._lastRun = Date.now()