@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- import { app , autoUpdater , ipcMain } from "electron" ;
17+ import { autoUpdater , ipcMain } from "electron" ;
1818
1919const UPDATE_POLL_INTERVAL_MS = 60 * 60 * 1000 ;
2020const INITIAL_UPDATE_DELAY_MS = 30 * 1000 ;
@@ -50,20 +50,14 @@ export function start(updateBaseUrl: string): void {
5050 }
5151 try {
5252 let url : string ;
53- // For reasons best known to Squirrel, the way it checks for updates
54- // is completely different between macOS and windows. On macOS, it
55- // hits a URL that either gives it a 200 with some json or
56- // 204 No Content. On windows it takes a base path and looks for
57- // files under that path.
53+ let serverType : "json" | undefined ;
54+
5855 if ( process . platform === 'darwin' ) {
59- // include the current version in the URL we hit. Electron doesn't add
60- // it anywhere (apart from the User-Agent) so it's up to us. We could
61- // (and previously did) just use the User-Agent, but this doesn't
62- // rely on NSURLConnection setting the User-Agent to what we expect,
63- // and also acts as a convenient cache-buster to ensure that when the
64- // app updates it always gets a fresh value to avoid update-looping.
65- url = `${ updateBaseUrl } macos/?localVersion=${ encodeURIComponent ( app . getVersion ( ) ) } ` ;
56+ // On macOS it takes a JSON file with a map between versions and their URLs
57+ url = `${ updateBaseUrl } macos/releases.json` ;
58+ serverType = "json" ;
6659 } else if ( process . platform === 'win32' ) {
60+ // On windows it takes a base path and looks for files under that path.
6761 url = `${ updateBaseUrl } win32/${ process . arch } /` ;
6862 } else {
6963 // Squirrel / electron only supports auto-update on these two platforms.
@@ -75,7 +69,7 @@ export function start(updateBaseUrl: string): void {
7569
7670 if ( url ) {
7771 console . log ( `Update URL: ${ url } ` ) ;
78- autoUpdater . setFeedURL ( { url } ) ;
72+ autoUpdater . setFeedURL ( { url, serverType } ) ;
7973 // We check for updates ourselves rather than using 'updater' because we need to
8074 // do it in the main process (and we don't really need to check every 10 minutes:
8175 // every hour should be just fine for a desktop app)
0 commit comments