Improve valid vencord install checks
This commit is contained in:
parent
c5ac3e64a6
commit
28ad4a6f73
3 changed files with 9 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "VencordDesktop",
|
||||
"version": "0.2.9",
|
||||
"version": "0.2.8",
|
||||
"private": true,
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { app, dialog, ipcMain, session, shell } from "electron";
|
||||
import { existsSync, mkdirSync, readFileSync, watch } from "fs";
|
||||
import { mkdirSync, readFileSync, watch } from "fs";
|
||||
import { open, readFile } from "fs/promises";
|
||||
import { release } from "os";
|
||||
import { join } from "path";
|
||||
|
@ -17,7 +17,7 @@ import { autoStart } from "./autoStart";
|
|||
import { VENCORD_FILES_DIR, VENCORD_QUICKCSS_FILE, VENCORD_THEMES_DIR } from "./constants";
|
||||
import { mainWin } from "./mainWindow";
|
||||
import { Settings } from "./settings";
|
||||
import { FILES_TO_DOWNLOAD } from "./utils/vencordLoader";
|
||||
import { isValidVencordInstall } from "./utils/vencordLoader";
|
||||
|
||||
ipcMain.on(IpcEvents.GET_VENCORD_PRELOAD_FILE, e => {
|
||||
e.returnValue = join(VENCORD_FILES_DIR, "vencordDesktopPreload.js");
|
||||
|
@ -112,9 +112,7 @@ ipcMain.handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
|
|||
if (!res.filePaths.length) return "cancelled";
|
||||
|
||||
const dir = res.filePaths[0];
|
||||
for (const file of FILES_TO_DOWNLOAD) {
|
||||
if (!existsSync(join(dir, file))) return "invalid";
|
||||
}
|
||||
if (!isValidVencordInstall(dir)) return "invalid";
|
||||
|
||||
return dir;
|
||||
});
|
||||
|
|
|
@ -55,8 +55,12 @@ export async function downloadVencordFiles() {
|
|||
);
|
||||
}
|
||||
|
||||
export function isValidVencordInstall(dir: string) {
|
||||
return FILES_TO_DOWNLOAD.every(f => existsSync(join(dir, f)));
|
||||
}
|
||||
|
||||
export async function ensureVencordFiles() {
|
||||
if (existsSync(join(VENCORD_FILES_DIR, "vencordDesktopMain.js"))) return;
|
||||
if (isValidVencordInstall(VENCORD_FILES_DIR)) return;
|
||||
mkdirSync(VENCORD_FILES_DIR, { recursive: true });
|
||||
|
||||
await downloadVencordFiles();
|
||||
|
|
Loading…
Reference in a new issue