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

auto-updater-win.js downloads updates twice when available. #5057

Closed
djpereira opened this Issue Apr 6, 2016 · 12 comments

Comments

Projects
None yet
@djpereira
Contributor

djpereira commented Apr 6, 2016

  • Electron version: 0.37.3
  • Operating system: Windows

When you look at the code for auto-updater-win.js, squirrelUpdate.download gets called and if succesful then squirrelUpdate.update gets called too.

AutoUpdater.prototype.checkForUpdates = function () {
  if (!this.updateURL) {
    return this.emitError('Update URL is not set')
  }
  if (!squirrelUpdate.supported()) {
    return this.emitError('Can not find Squirrel')
  }
  this.emit('checking-for-update')
  squirrelUpdate.download(this.updateURL, (error, update) => {
    if (error != null) {
      return this.emitError(error)
    }
    if (update == null) {
      return this.emit('update-not-available')
    }
    this.emit('update-available')
    squirrelUpdate.update(this.updateURL, (error) => {
      var date, releaseNotes, version
      if (error != null) {
        return this.emitError(error)
      }
      releaseNotes = update.releaseNotes
      version = update.version

      // Following information is not available on Windows, so fake them.
      date = new Date()
      this.emit('update-downloaded', {}, releaseNotes, version, date, this.updateURL, () => {
        this.quitAndInstall()
      })
    })
  })
}

These two calls in turn call Squirrel's Update.exe --download and Update.exe --update.

If you look at Squirrel's source code, in both cases this will call UpdateManager.DownloadReleases, effectively downloading the whole release twice.

I may be wrong, but I think it could possibly be more efficient to just call Update.exe --update and that's it. Please let me know if I'm missing something.

@kevinsawicki

This comment has been minimized.

Contributor

kevinsawicki commented Apr 6, 2016

I thought calling Update.exe --update would use the already downloaded version from Update.exe --download so it would only be downloaded once and just update accordingly.

@paulcbetts is this not the case? Will this cause double downloads?

@paulcbetts

This comment has been minimized.

Contributor

paulcbetts commented Apr 7, 2016

@paulcbetts is this not the case? Will this cause double downloads?

We shouldn't need to double-download, but I can look into it

@zcbenz zcbenz added the bug label Apr 8, 2016

@friksa

This comment has been minimized.

friksa commented Apr 17, 2016

I am seeing a double download in the logs too when a new update is available

@philipgiuliani

This comment has been minimized.

philipgiuliani commented Apr 28, 2016

I can confirm this on my windows builds.

@jrx-jsj

This comment has been minimized.

jrx-jsj commented Aug 1, 2016

There shouldn't be a "download" call but a check for update, as it is stated in the event names, and then calling update (including download) just after the update-available event has been emitted.

It seems that newer versions of Squirrel Updater.exe has the checkForUpdate command line option, so we can get the expected JSON from it instead of download. Please look at https://github.com/Squirrel/Squirrel.Windows/blob/master/src/Update/Program.cs, line 108.

The one that is generated with electron-builder doesn't seem to have that command line option.

@karlpablo

This comment has been minimized.

karlpablo commented Feb 24, 2017

I am seeing this issue as well.

@edunad

This comment has been minimized.

edunad commented Mar 3, 2017

Same here, on windows builds

@qbunt

This comment has been minimized.

qbunt commented Mar 15, 2017

+1 for the same issue.

@stouchardIpso

This comment has been minimized.

stouchardIpso commented Apr 12, 2017

+1 same issue.

1 similar comment
@iamiota

This comment has been minimized.

iamiota commented Jul 6, 2017

+1 same issue.

@mynetx

This comment has been minimized.

Contributor

mynetx commented Sep 10, 2017

We have an app that has 900MB update size, so letting the user wait for 2x 900MB is really not good. How can we fix this ASAP?

mynetx added a commit to jublo/electron that referenced this issue Sep 10, 2017

Use Squirrel.Windows --checkForUpdate
Avoid downloading updates twice. Fix electron#5057.

mynetx added a commit to jublo/electron that referenced this issue Sep 10, 2017

Use Squirrel.Windows --checkForUpdate
Avoid downloading updates twice. Fix electron#5057.

@poiru poiru closed this in #10483 Sep 27, 2017

poiru added a commit that referenced this issue Sep 27, 2017

Use Squirrel.Windows --checkForUpdate
This cherry-picks #10483 to fix #5057.

poiru added a commit that referenced this issue Sep 27, 2017

Use Squirrel.Windows --checkForUpdate
This cherry-picks #10483 to fix #5057.
@Ali8668

This comment has been minimized.

Ali8668 commented Oct 27, 2018

Goood

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