Skip to content

Commit

Permalink
Don't check for updates if we already have one downloaded and queued
Browse files Browse the repository at this point in the history
This is a punt at fixing element-hq/element-web#12433,
on the assumption that multiple update checks might collide with a
download which are already queued to install.  It also avoids repeatedly
re-downloading the same update on every check, as per the Note: on
https://github.com/electron/electron/blob/main/docs/api/auto-updater.md#autoupdatercheckforupdates

However, it means that you may have to upgrade twice if you wait more than 24h to install
a new build - and if you cancel an upgrade prompt, you'll have to either restart
the app or explicitly check for a new version to get upgrades working again.
However, this is less annoying than having the app fail to relaunch after upgrading.
  • Loading branch information
ara4n committed Jul 3, 2022
1 parent 389f6f4 commit 45a9156
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ function installUpdate(): void {

function pollForUpdates(): void {
try {
autoUpdater.checkForUpdates();
// If we've already got a new update downloaded, then stop
// trying to check for new ones, as according to the doc
// at https://github.com/electron/electron/blob/main/docs/api/auto-updater.md#autoupdatercheckforupdates
// we'll just keep re-downloading the same update.
// As a hunch, this might also be causing
// https://github.com/vector-im/element-web/issues/12433
// due to the update checks colliding with the pending install
// somehow
if (!latestUpdateDownloaded) {
autoUpdater.checkForUpdates();
}
else {
console.log("Skipping update check as download already present");
}
} catch (e) {
console.log('Couldn\'t check for update', e);
}
Expand Down

0 comments on commit 45a9156

Please sign in to comment.