We have separate release channels based on the configuration of the user (beta|stable).
Lets say these are the current versions:
Behavior we would like to achieve:
When a user from the beta channel wants to go back to the stable channel the application should auto-update (downgrade) to the latest stable version.
Possible solutions:
GenericProvider.ts
async shouldForceUpdate(): Promise<boolean> {
const latestChannel = this.channel
// currentChannel how to get this?
return latestChannel != currentChannel
}
AppUpdater.ts
const forceUpdate = await client.shouldForceUpdate()
if (!forceUpdate && !isVersionGreaterThan(latestVersion, currentVersion)) {
this.updateAvailable = false
if (this.logger != null) {
this.logger.info(`Update for version ${versionInfo.version} is not available`)
}
this.emit("update-not-available")
return {
versionInfo: versionInfo,
}
}
and small updates on all the other Providers + interface Provider
updateOnVersionChange or canDowngrade (better name suggestions are welcome) that will auto-update the application if latestVersion != currentVersion.AppUpdater.ts
if ((updateOnVersionChange && latestVersion == currentVersion) || (!updateOnVersionChange && !isVersionGreaterThan(latestVersion, currentVersion))) {
this.updateAvailable = false
if (this.logger != null) {
this.logger.info(`Update for version ${versionInfo.version} is not available`)
}
this.emit("update-not-available")
return {
versionInfo: versionInfo,
}
}
Let me know if we could integrate any of these solutions with a pull request or if you have an even better proposal to achieve this "downgrade" on channel change behavior.
Thanks!
How do we know "check the current application channel "?
It would only be for GenericProvider and we could compare the (current application) channel inside resources/app-update.yml with the channel that is set inside autoUpdater.setFeedURL.
So for example we have this inside app-update.yml:
provider: generic
url: 'https://releases.test.com'
channel: beta
And we update the autoUpdater like this:
autoUpdater.setFeedURL({ provider: "generic", url: "https://releases.test.com", channel: "stable" });
This would be a solution that only affects the GenericProvider.
The other solution would be to add a configuration option like updateOnVersionChange or canDowngrade (see above).
Relates #1182
allowPrerelease is added. If true, downgrade will be allowed.allowDowngrade option is added. Defaults to true if application version contains prerelease components (e.g. 0.12.1-alpha.1, here alpha is a prerelease component), otherwise false. So, if version are not equal — we just update to versions in the update info. If you set channel or somehow else set lower version in the update info — it is your developer decision :) No need to implement at little bit complex channel check.
Most helpful comment
allowDowngradeoption is added. Defaults totrueif application version contains prerelease components (e.g.0.12.1-alpha.1, herealphais a prerelease component), otherwisefalse. So, if version are not equal — we just update to versions in the update info. If you set channel or somehow else set lower version in the update info — it is your developer decision :) No need to implement at little bit complex channel check.