@@ -4,9 +4,11 @@ import path from 'path';
44import { URL } from 'url' ;
55
66import { newError , PublishConfiguration } from 'builder-util-runtime' ;
7+ import Electron from 'electron' ;
78import { AppUpdater , Provider , ResolvedUpdateFileInfo , UpdateInfo } from 'electron-updater' ;
89import { ProviderRuntimeOptions } from 'electron-updater/out/providers/Provider' ;
910import fetch from 'node-fetch' ;
11+ import semver from 'semver' ;
1012
1113import Logging from '@/utils/logging' ;
1214import paths from '@/utils/paths' ;
@@ -125,9 +127,28 @@ export async function hasQueuedUpdate(): Promise<boolean> {
125127 const rawCache = await fs . promises . readFile ( gCachePath , 'utf-8' ) ;
126128 const cache : LonghornCache = JSON . parse ( rawCache ) ;
127129
128- if ( cache . isInstallable ) {
129- return true ;
130+ if ( ! cache . isInstallable ) {
131+ return false ;
130132 }
133+
134+ // The isInstallable flag isn't going to get clear _right_ after an update;
135+ // in which case, we need to check that the release is newer than the
136+ // current version.
137+ const currentVersion = semver . parse ( Electron . app . getVersion ( ) , { loose : true } ) ;
138+ const stagedVersion = semver . parse ( cache . release . tag , { loose : true } ) ;
139+
140+ if ( ! currentVersion || ! stagedVersion ) {
141+ console . log ( `Error parsing staged versions: ${ currentVersion ?? '<none>' } -> ${ stagedVersion ?? '<none>' } ` ) ;
142+
143+ return false ;
144+ }
145+ if ( semver . gte ( currentVersion , stagedVersion ) ) {
146+ console . log ( `Staged version ${ stagedVersion } not greater than current version ${ currentVersion } , skipping.` ) ;
147+
148+ return false ;
149+ }
150+
151+ return true ;
131152 } catch ( error ) {
132153 if ( error . code !== 'ENOENT' ) {
133154 console . error ( 'Could not check for queued update:' , error ) ;
0 commit comments