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

Electron Updater downloads update multiple times #1788

Closed
ccorcos opened this issue Jul 4, 2017 · 1 comment
Closed

Electron Updater downloads update multiple times #1788

ccorcos opened this issue Jul 4, 2017 · 1 comment

Comments

@ccorcos
Copy link

ccorcos commented Jul 4, 2017

  • Version:
"electron": "1.6.2",
"electron-builder": "16.6.1",
"electron-updater": "^1.14.0",
  • Target: Mac, Windows

We check for updates every minute, then display a banner in the app for users to quit and install at their leisure. Our code looks like this:

ipcMain.on("notion:install-update", () => {
	if (updateIsReady) {
		autoUpdater.quitAndInstall()
	}
})

autoUpdater.on("update-downloaded", () => {
	updateIsReady = true
	BrowserWindow.getAllWindows().forEach(window => {
		window.webContents.send("notion:update-ready")
	})
})

if (!isDev) {
	setInterval(() => {
		autoUpdater.checkForUpdates()
	}, 60 * 1000)
}

The problem we're having right now is that if the user ignores the banner and decides to quit and install later, the autoupdater still downloads the app again and again every minute!

~ ❯❯❯ tail -f ~/Library/Logs/Notion/log.log
[2017-07-04 12:45:46:0997] [info] Checking for update
[2017-07-04 12:45:47:0356] [info] Found version 0.1.10 (url: https://s3-us-west-2.amazonaws.com/desktop-release/Notion-0.1.10-mac.zip)
[2017-07-04 12:45:47:0358] [info] Downloading update from https://s3-us-west-2.amazonaws.com/desktop-release/Notion-0.1.10-mac.zip
[2017-07-04 12:46:03:0052] [info] New version 0.1.10 has been downloaded
[2017-07-04 12:46:47:0006] [info] Checking for update
[2017-07-04 12:46:47:0181] [info] Found version 0.1.10 (url: https://s3-us-west-2.amazonaws.com/desktop-release/Notion-0.1.10-mac.zip)
[2017-07-04 12:46:47:0183] [info] Downloading update from https://s3-us-west-2.amazonaws.com/desktop-release/Notion-0.1.10-mac.zip
[2017-07-04 12:47:03:0886] [info] New version 0.1.10 has been downloaded
[2017-07-04 12:47:47:0014] [info] Checking for update
[2017-07-04 12:47:47:0227] [info] Found version 0.1.10 (url: https://s3-us-west-2.amazonaws.com/desktop-release/Notion-0.1.10-mac.zip)
[2017-07-04 12:47:47:0228] [info] Downloading update from https://s3-us-west-2.amazonaws.com/desktop-release/Notion-0.1.10-mac.zip
[2017-07-04 12:48:05:0861] [info] New version 0.1.10 has been downloaded

Lots of people leave our application open in the background so its costing us lot of money on S3 (~$2k/day!).

On our side, we have a fairly simple fix:

if (!isDev) {
	setInterval(() => {
		if (!updateIsReady) {
			autoUpdater.checkForUpdates()
		}
	}, 60 * 1000)
}

However, I feel like this is something that could be handled by the updater which would prevent these issues for others in the future.

@develar
Copy link
Member

develar commented Jul 5, 2017

autoUpdater.autoDownload = false

https://github.com/electron-userland/electron-builder/wiki/Auto-Update#module_electron-updater.AppUpdater+downloadUpdate

should help you, but in general — yes, next check for updates must not download again.

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

No branches or pull requests

2 participants