1
0
Fork 0
mirror of https://gitlab.com/futo-org/fcast.git synced 2025-07-24 02:46:59 +00:00

Electron: Initial support for most of protocol v3

This commit is contained in:
Michael Hollister 2025-06-03 14:29:25 -05:00
parent a83f92d874
commit 72d5c10918
13 changed files with 764 additions and 216 deletions

View file

@ -6,6 +6,7 @@ import { app } from 'electron';
import { Store } from './Store';
import sudo from 'sudo-prompt';
import { Logger, LoggerType } from 'common/Logger';
import { fetchJSON } from './Main';
const cp = require('child_process');
const extract = require('extract-zip');
@ -91,28 +92,6 @@ export class Updater {
Store.set('updater', updaterSettings);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private static async fetchJSON(url: string): Promise<any> {
return new Promise((resolve, reject) => {
https.get(url, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
try {
resolve(JSON.parse(data));
} catch (err) {
reject(err);
}
});
}).on('error', (err) => {
reject(err);
});
});
}
private static async downloadFile(url: string, destination: string): Promise<void> {
return new Promise((resolve, reject) => {
const file = fs.createWriteStream(destination);
@ -345,7 +324,7 @@ export class Updater {
logger.info('Checking for updates...');
try {
Updater.releasesJson = await Updater.fetchJSON(`${Updater.baseUrl}/releases_v${Updater.supportedReleasesJsonVersion}.json`.toString()) as ReleaseInfo;
Updater.releasesJson = await fetchJSON(`${Updater.baseUrl}/releases_v${Updater.supportedReleasesJsonVersion}.json`.toString()) as ReleaseInfo;
const localChannelVersion: number = Updater.localPackageJson.channelVersion ? Updater.localPackageJson.channelVersion : 0;
const currentChannelVersion: number = Updater.releasesJson.channelCurrentVersions[Updater.updateChannel] ? Updater.releasesJson.channelCurrentVersions[Updater.updateChannel] : 0;