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

How to use allowPrerelease? #1923

Closed
akashnimare opened this issue Aug 9, 2017 · 11 comments
Closed

How to use allowPrerelease? #1923

akashnimare opened this issue Aug 9, 2017 · 11 comments

Comments

@akashnimare
Copy link
Contributor

akashnimare commented Aug 9, 2017

  • Version:
    17.10.0
  • electron-updater :
    1.11.2

In our app we have added an option for getting the beta updates.

image

This is how we are setting the allowPrerelease parameter -

autoUpdater.allowPrerelease = ConfigUtil.getConfigItem('betaUpdate') || false;

Full code here. Even after setting it ConfigUtil.getConfigItem('betaUpdate') to true, app don't fetch the latest version. Am I missing something here?

Logs after setting the betaUpdate option and restarting app-

[2017-08-10 04:29:22:0724] [info] Checking for update
[2017-08-10 04:29:25:0793] [info] Update for version 1.2.0-beta is not available (latest version: 0.5.10)
[2017-08-10 04:32:13:0798] [info] Checking for update
[2017-08-10 04:32:16:0665] [info] Update for version 1.2.0-beta is not available (latest version: 0.5.10)
[2017-08-10 04:54:56:0201] [info] Checking for update
[2017-08-10 04:54:59:0454] [info] Update for version 1.2.0-beta is not available (latest version: 0.5.10)

Steps to reproduce -

  • Download prerelease v1.2.0-beta
  • Install app > Setting page > Set get beta updates to true/on
  • Restart app
  • Check logs in /Users/%USERNAME%/Library/Application Support/Zulip
@akashnimare
Copy link
Contributor Author

FYI here are the beta releases -
https://github.com/zulip/zulip-electron/releases/

@develar
Copy link
Member

develar commented Aug 16, 2017

Sorry for late response. I see, that now you use latest versions of electron-updater. So, I will check manually, because according to code should work.

@akashnimare
Copy link
Contributor Author

I don't know what was the problem but it works with v19.19.1. v1.3.0-beta was built on v19.19.1 and I just pushed v1.4.0-beta and v1.3.0-beta was able to fetch the latest pre-release.

@akashnimare
Copy link
Contributor Author

However, I have noticed that my app was not able to auto-relaunch itself once the updater finished downloading updates. When I choose Install and Relauch option which basically triggers -
setTimeout(() => autoUpdater.quitAndInstall(), 1);
my app got closed (not quit) and nothing happened. I had to quit the app using CMD+Q and then had to restart the app and then I got the latest version. @develar Is this a known bug?

@develar
Copy link
Member

develar commented Aug 21, 2017

@akashnimare Please see #1604 (comment)

@akashnimare
Copy link
Contributor Author

Tried using following code but still not working -

autoUpdater.on('update-downloaded', (event, info) => {
	// Ask user to update the app
	dialog.showMessageBox({
		type: 'question',
		buttons: ['Install and Relaunch', 'Install Later'],
		defaultId: 0,
		message: 'A new version of ' + app.getName() + ' has been downloaded',
		detail: 'It will be installed the next time you restart the application'
	}, response => {
		if (response === 0) {
			setTimeout(() => {
				app.removeAllListeners('window-all-closed');
				app.removeAllListeners('close');
				autoUpdater.quitAndInstall();
			});
		}
	});
});
// Init for updates
autoUpdater.checkForUpdates();

Any idea what's going wrong here?
https://github.com/zulip/zulip-electron/blob/master/app/main/autoupdater.js#L35-L48
https://github.com/zulip/zulip-electron/blob/master/app/main/index.js#-L77-L249

@develar
Copy link
Member

develar commented Aug 25, 2017

@akashnimare Why do you use setTimeout? Please try setImmediate.

@akashnimare
Copy link
Contributor Author

Tried setImmediate also, still no luck.

@develar
Copy link
Member

develar commented Aug 25, 2017

Are you really need to show message box? May be just show notification that new version is available? To not interrupt users?

@develar
Copy link
Member

develar commented Aug 25, 2017

@akashnimare
Copy link
Contributor Author

Calling app.quit() manually did the job.

setTimeout(() => {
	autoUpdater.quitAndInstall();
	app.quit();
}, 1000);

Just an idea — try to remove https://github.com/zulip/zulip-electron/blob/d17c685e4d0c240c25b111aeba8c25c285b19892/app/main/index.js#L77

Can't remove this event, since we don't want to close the app when user closes the app ( using CMD + W etc), we just hide the window. Ideally, when you click on X button app gets hidden on macOS, we implemented the same behaviour on Linux and Windows as well using close event.

Thanks for the help :)

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