File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change 1
1
/* eslint global-require: off, no-console: off */
2
2
import { app , nativeTheme } from 'electron'
3
+ import log from 'electron-log'
3
4
import path from 'path'
4
5
import {
5
6
initElectronHandlers ,
6
7
initLogging ,
7
8
WindowType ,
8
9
windowFactory ,
9
10
AboutPanelOptions ,
10
- checkForUpdate ,
11
+ initAutoUpdateChecks ,
11
12
installExtensions ,
12
13
initTray ,
13
14
initAutoUpdaterHandlers ,
@@ -70,10 +71,12 @@ const init = async () => {
70
71
71
72
await windowFactory ( WindowType . Main , splashWindow , { parsedDeepLink } )
72
73
73
- checkForUpdate ( process . env . MANUAL_UPGRADES_LINK || process . env . UPGRADES_LINK )
74
- } catch ( _err ) {
75
- const error = _err as Error
76
- console . log ( wrapErrorMessageSensitiveData ( error ) )
74
+ initAutoUpdateChecks (
75
+ process . env . MANUAL_UPGRADES_LINK || process . env . UPGRADES_LINK ,
76
+ parseInt ( process . env . RIAUTOUPDATEINTERVAL , 10 ) || 84 * 3600 * 1000 ,
77
+ )
78
+ } catch ( err ) {
79
+ log . error ( wrapErrorMessageSensitiveData ( err as Error ) )
77
80
}
78
81
}
79
82
Original file line number Diff line number Diff line change @@ -33,7 +33,19 @@ export const checkForUpdate = async (url: string = '') => {
33
33
autoUpdater . autoDownload = true
34
34
autoUpdater . autoInstallOnAppQuit = true
35
35
36
- await autoUpdater . checkForUpdates ( )
36
+ const res = await autoUpdater . checkForUpdates ( )
37
+
38
+ if ( res ?. downloadPromise ) {
39
+ await res . downloadPromise
40
+ }
41
+ }
42
+
43
+ export const initAutoUpdateChecks = ( url = '' , interval = 84 * 3600 * 1000 ) => {
44
+ checkForUpdate ( url )
45
+ . catch ( ( e ) => log . error ( wrapErrorMessageSensitiveData ( e ) ) )
46
+ . finally ( ( ) => {
47
+ setTimeout ( ( ) => initAutoUpdateChecks ( url , interval ) , interval )
48
+ } )
37
49
}
38
50
39
51
export const quitAndInstallUpdate = ( ) => {
You can’t perform that action at this time.
0 commit comments