I am implementing autoupdate in my Electron app using squirrel. When the updates are downloaded I show the user a dialog giving them two options:
- Quit the app and install the update immediately (using
autoUpdater.quitAndInstall()
) - Temporarily set aside the update and install it the next time the app starts
Option 1 - quite and install now works fine, but I cannot get option 2 - install at next app launch - to work.
The desired behaviour is that if the user chooses to install later, the update is installed immediately the next time the app is launched.
In my app, I handle the autoUpdater update-downloaded
event. I also called checkForUpdates
when the app starts. I assumed that if the update was ignored, then when the app is next launched the call to checkForUpdates
would cause squirrel to notice the existing download, emit the update-downloaded
event and the user would get asked again whether they want to install the update. However, no update-downloaded
event is emitted.
Second, if the user selects install later, I wrote a flag to a userData
file telling the app to call autoUpdater.quitAndInstall
the next time the app launched. This gives an error since this method can only be called after update-downloaded
has been emitted.
So how can I get this to work? Do I need to somehow delete the existing download so it is downloaded again when the app is next launched? This doesn't seem right.