Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to "auto-downgrade" the application on channel change #1149

Closed
tvanro opened this issue Jan 20, 2017 · 5 comments · May be fixed by qcif/data-curator#563
Closed

Make it possible to "auto-downgrade" the application on channel change #1149

tvanro opened this issue Jan 20, 2017 · 5 comments · May be fixed by qcif/data-curator#563

Comments

@tvanro
Copy link

tvanro commented Jan 20, 2017

  • 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!

@develar
Copy link
Member

develar commented Jan 24, 2017

How do we know "check the current application channel "?

@tvanro
Copy link
Author

tvanro commented Jan 25, 2017

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).

@develar
Copy link
Member

develar commented Jan 29, 2017

Relates #1182

@develar
Copy link
Member

develar commented Apr 16, 2017

#1391 will be solved soon and option allowPrerelease is added. If true, downgrade will be allowed.

@develar
Copy link
Member

develar commented Apr 16, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants