From 8b0911b86a4f070122a1c5ba773bbf65a88a2ecd Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 17 Nov 2022 00:44:52 +0100 Subject: [PATCH] Updater: Ignore non release commits --- src/ipcMain/updater/http.ts | 17 +++++++++++------ src/patcher.ts | 1 - 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ipcMain/updater/http.ts b/src/ipcMain/updater/http.ts index 5b3f0ff54..523340f4c 100644 --- a/src/ipcMain/updater/http.ts +++ b/src/ipcMain/updater/http.ts @@ -29,7 +29,7 @@ import { get } from "../simpleGet"; import { calculateHashes, serializeErrors } from "./common"; const API_BASE = `https://api.github.com/repos/${gitRemote}`; -let PendingUpdates = [] as [string, Buffer][]; +let PendingUpdates = [] as [string, string][]; async function githubGet(endpoint: string) { return get(API_BASE + endpoint, { @@ -46,6 +46,9 @@ async function githubGet(endpoint: string) { } async function calculateGitChanges() { + const isOutdated = await fetchUpdates(); + if (!isOutdated) return []; + const res = await githubGet(`/compare/${gitHash}...HEAD`); const data = JSON.parse(res.toString("utf-8")); @@ -63,18 +66,20 @@ async function fetchUpdates() { const data = JSON.parse(release.toString()); const hash = data.name.slice(data.name.lastIndexOf(" ") + 1); if (hash === gitHash) - return true; + return false; - await Promise.all(data.assets.map(async ({ name, browser_download_url }) => { + data.assets.forEach(({ name, browser_download_url }) => { if (["patcher.js", "preload.js", "renderer.js"].some(s => name.startsWith(s))) { - PendingUpdates.push([name, await get(browser_download_url)]); + PendingUpdates.push([name, browser_download_url]); } - })); + }); return true; } async function applyUpdates() { - await Promise.all(PendingUpdates.map(([name, data]) => writeFile(join(__dirname, name), data))); + await Promise.all(PendingUpdates.map( + async ([name, data]) => writeFile(join(__dirname, name), await get(data))) + ); PendingUpdates = []; return true; } diff --git a/src/patcher.ts b/src/patcher.ts index eb607b93a..28910b7af 100644 --- a/src/patcher.ts +++ b/src/patcher.ts @@ -152,6 +152,5 @@ if (readFileSync(injectorPath, "utf-8").includes('require("../app.asar")')) { return loadModule.apply(this, arguments); }; } else { - console.log(require.main!.filename); require(require.main!.filename); }