Electron-builder: Make it possible to "auto-downgrade" the application on channel change

Created on 20 Jan 2017  Â·  5Comments  Â·  Source: electron-userland/electron-builder

  • electron-builder: 11.5.0
  • electron-auto-updater: 1.0.0

  • Target: win32


We have separate release channels based on the configuration of the user (beta|stable).
Lets say these are the current versions:

  • beta: 1.2.0-beta.4
  • stable: 1.1.0

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:

  1. Always update on channel change (check the current application channel with the requested channel)

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

  1. Add a configuration option like 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!

electron-updater feature

Most helpful comment

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.

All 5 comments

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

1391 will be solved soon and option 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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

omarkilani picture omarkilani  Â·  3Comments

StickNitro picture StickNitro  Â·  3Comments

NPellet picture NPellet  Â·  3Comments

noahprince22 picture noahprince22  Â·  3Comments

JohnWeisz picture JohnWeisz  Â·  3Comments