@@ -28,6 +28,16 @@ const url = require('url');
2828
2929const VectorMenu = require ( './vectormenu' ) ;
3030
31+ let vectorConfig = { } ;
32+ try {
33+ vectorConfig = require ( '../../vector/config.json' ) ;
34+ } catch ( e ) {
35+ // it would be nice to check the error code here and bail if the config
36+ // is unparseable, but we get MODULE_NOT_FOUND in the case of a missing
37+ // file or invalid json, so node is just very unhelpful.
38+ // Continue with the defaults (ie. an empty config)
39+ }
40+
3141const PERMITTED_URL_SCHEMES = [
3242 'http:' ,
3343 'https:' ,
@@ -91,29 +101,20 @@ function pollForUpdates() {
91101 }
92102}
93103
94- // handle uncaught errors otherwise it displays
95- // stack traces in popup dialogs, which is terrible (which
96- // it will do any time the auto update poke fails, and there's
97- // no other way to catch this error).
98- // Assuming we generally run from the console when developing,
99- // this is far preferable.
100- process . on ( 'uncaughtException' , function ( error ) {
101- console . log ( "Unhandled exception" , error ) ;
102- } ) ;
103-
104- electron . ipcMain . on ( 'install_update' , installUpdate ) ;
105-
106- electron . app . on ( 'ready' , ( ) => {
104+ function startAutoUpdate ( update_url ) {
105+ if ( update_url . slice ( - 1 ) !== '/' ) {
106+ update_url = update_url + '/' ;
107+ }
107108 try {
108109 // For reasons best known to Squirrel, the way it checks for updates
109110 // is completely different between macOS and windows. On macOS, it
110111 // hits a URL that either gives it a 200 with some json or
111112 // 204 No Content. On windows it takes a base path and looks for
112113 // files under that path.
113114 if ( process . platform == 'darwin' ) {
114- electron . autoUpdater . setFeedURL ( "https://riot.im/autoupdate/desktop/" ) ;
115+ electron . autoUpdater . setFeedURL ( update_url ) ;
115116 } else if ( process . platform == 'win32' ) {
116- electron . autoUpdater . setFeedURL ( "https://riot.im/download/desktop/ win32/" ) ;
117+ electron . autoUpdater . setFeedURL ( update_url + ' win32/' ) ;
117118 } else {
118119 // Squirrel / electron only supports auto-update on these two platforms.
119120 // I'm not even going to try to guess which feed style they'd use if they
@@ -133,6 +134,27 @@ electron.app.on('ready', () => {
133134 // will fail if running in debug mode
134135 console . log ( "Couldn't enable update checking" , err ) ;
135136 }
137+ }
138+
139+ // handle uncaught errors otherwise it displays
140+ // stack traces in popup dialogs, which is terrible (which
141+ // it will do any time the auto update poke fails, and there's
142+ // no other way to catch this error).
143+ // Assuming we generally run from the console when developing,
144+ // this is far preferable.
145+ process . on ( 'uncaughtException' , function ( error ) {
146+ console . log ( "Unhandled exception" , error ) ;
147+ } ) ;
148+
149+ electron . ipcMain . on ( 'install_update' , installUpdate ) ;
150+
151+ electron . app . on ( 'ready' , ( ) => {
152+ if ( vectorConfig . update_url ) {
153+ console . log ( "Starting auto update with URL: " + vectorConfig . update_url ) ;
154+ startAutoUpdate ( vectorConfig . update_url ) ;
155+ } else {
156+ console . log ( "No update_url is defined: auto update is disabled" ) ;
157+ }
136158
137159 mainWindow = new electron . BrowserWindow ( {
138160 icon : `${ __dirname } /../img/riot.ico` ,
0 commit comments