fix(xo-web/xoa-updater): handle all *-upgrade-needed states

Otherwise adding new namespaces in the updater will break state handling.
This commit is contained in:
Julien Fontanet 2020-02-18 15:28:55 +01:00
parent 88f43a8124
commit cb51f44a45

View File

@ -126,6 +126,10 @@ class XoaUpdater extends EventEmitter {
}) })
middle.on('end', end => { middle.on('end', end => {
this._lowState = end this._lowState = end
const { state } = end
if (state.endsWith('-upgrade-needed')) {
this.state('upgradeNeeded')
} else {
switch (this._lowState.state) { switch (this._lowState.state) {
case 'xoa-up-to-date': case 'xoa-up-to-date':
case 'xoa-upgraded': case 'xoa-upgraded':
@ -133,17 +137,13 @@ class XoaUpdater extends EventEmitter {
case 'installer-upgraded': case 'installer-upgraded':
this.state('upToDate') this.state('upToDate')
break break
case 'xoa-upgrade-needed':
case 'updater-upgrade-needed':
case 'installer-upgrade-needed':
this.state('upgradeNeeded')
break
case 'register-needed': case 'register-needed':
this.state('registerNeeded') this.state('registerNeeded')
break break
default: default:
this.state('error') this.state('error')
} }
}
this.log(end.level, end.message) this.log(end.level, end.message)
this._lastRun = Date.now() this._lastRun = Date.now()
this._waiting = false this._waiting = false