fix(proxy/backup.run): handle multiple self licenses
See xoa-support#3730 Previous code would fail if the first license returned was already expired.
This commit is contained in:
parent
d1dfd93e15
commit
c7f1469e1f
@ -153,6 +153,10 @@ export default class Appliance {
|
||||
|
||||
// A proxy can be bound to a unique license
|
||||
getSelfLicense() {
|
||||
return Disposable.use(getUpdater(), _ => _.call('getSelfLicenses').then(licenses => licenses[0]))
|
||||
return Disposable.use(getUpdater(), async updater => {
|
||||
const licenses = await updater.call('getSelfLicenses')
|
||||
const now = Date.now()
|
||||
return licenses.find(({ expires }) => expires === undefined || expires > now)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -107,8 +107,8 @@ export default class Backups {
|
||||
async function () {
|
||||
if (!__DEV__) {
|
||||
const license = await app.appliance.getSelfLicense()
|
||||
if (license === undefined || license.expires < Date.now()) {
|
||||
throw new Error('the proxy license is not valid')
|
||||
if (license === undefined) {
|
||||
throw new Error('no valid proxy license')
|
||||
}
|
||||
}
|
||||
return run.apply(this, arguments)
|
||||
|
Loading…
Reference in New Issue
Block a user