From 572eecc32254498a0aff86ce74c841ea3a184bf1 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Mon, 4 Dec 2023 21:56:34 +0100 Subject: [PATCH] Use feed.json with macos updater --- ts/updater/macos.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ts/updater/macos.ts b/ts/updater/macos.ts index 584f5f2a5..8df31981b 100644 --- a/ts/updater/macos.ts +++ b/ts/updater/macos.ts @@ -3,8 +3,10 @@ import { pathToFileURL } from 'url'; import { autoUpdater } from 'electron'; +import { writeFile } from 'fs/promises'; +import { join } from 'path'; -import { Updater } from './common'; +import { Updater, getTempDir } from './common'; import { explodePromise } from '../util/explodePromise'; import * as Errors from '../types/errors'; import { markShouldQuit } from '../../app/window_state'; @@ -59,8 +61,20 @@ export class MacOSUpdater extends Updater { resolve(); }); + // See: https://github.com/electron/electron/issues/5020#issuecomment-477636990 + const updateUrl = pathToFileURL(filePath).href; + + const tempDir = await getTempDir(); + const feedPath = join(tempDir, 'feed.json'); + await writeFile( + feedPath, + JSON.stringify({ + url: updateUrl, + }) + ); + autoUpdater.setFeedURL({ - url: pathToFileURL(filePath).href, + url: pathToFileURL(feedPath).href, serverType: 'json', }); autoUpdater.checkForUpdates();