This commit is contained in:
Vendicated 2024-07-19 01:20:09 +02:00
parent fbfbe33c0a
commit d9c469755b
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18
2 changed files with 9 additions and 7 deletions

View file

@ -22,7 +22,6 @@ import { dirname, join } from "path";
import { initIpc } from "./ipcMain";
import { RendererSettings } from "./settings";
import { migrateLegacyToAsar } from "./updater/http";
import { IS_VANILLA } from "./utils/constants";
console.log("[Vencord] Starting up...");
@ -31,7 +30,7 @@ console.log("[Vencord] Starting up...");
const isLegacyNonAsarVencord = IS_STANDALONE && !__dirname.endsWith(".asar");
if (isLegacyNonAsarVencord) {
console.warn("This is a legacy non asar install! Migrating to asar and restarting...");
migrateLegacyToAsar();
require("./updater/http").migrateLegacyToAsar();
}
// Our injector file at app/index.js

View file

@ -19,7 +19,7 @@
import { IpcEvents } from "@shared/IpcEvents";
import { VENCORD_USER_AGENT } from "@shared/vencordUserAgent";
import { app, dialog, ipcMain } from "electron";
import { writeFile } from "fs/promises";
import { writeFileSync as originalWriteFileSync } from "original-fs";
import { join } from "path";
import gitHash from "~git-hash";
@ -76,7 +76,7 @@ async function applyUpdates() {
if (!PendingUpdate) return true;
const data = await get(PendingUpdate);
await writeFile(__dirname, data);
originalWriteFileSync(__dirname, data);
PendingUpdate = null;
@ -90,10 +90,13 @@ ipcMain.handle(IpcEvents.BUILD, serializeErrors(applyUpdates));
export async function migrateLegacyToAsar() {
try {
const data = await get(`https://github.com/${gitRemote}/releases/latest/desktop.asar`);
await writeFile(join(__dirname, "../vencord.asar"), data);
await writeFile(__filename, '// Legacy shim for new asar\n\nrequire("../vencord.asar");');
const data = await get(`https://github.com/${gitRemote}/releases/latest/download/desktop.asar`);
originalWriteFileSync(join(__dirname, "../vencord.asar"), data);
originalWriteFileSync(__filename, '// Legacy shim for new asar\n\nrequire("../vencord.asar");');
app.relaunch();
app.quit();
} catch (e) {
console.error("Failed to migrate to asar", e);