mirror of
https://github.com/Vencord/Vesktop.git
synced 2025-02-23 05:35:09 +00:00
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",
|
"name": "VencordDesktop",
|
||||||
"version": "0.2.9",
|
"version": "0.2.8",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "",
|
"description": "",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { app, dialog, ipcMain, session, shell } from "electron";
|
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 { open, readFile } from "fs/promises";
|
||||||
import { release } from "os";
|
import { release } from "os";
|
||||||
import { join } from "path";
|
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 { VENCORD_FILES_DIR, VENCORD_QUICKCSS_FILE, VENCORD_THEMES_DIR } from "./constants";
|
||||||
import { mainWin } from "./mainWindow";
|
import { mainWin } from "./mainWindow";
|
||||||
import { Settings } from "./settings";
|
import { Settings } from "./settings";
|
||||||
import { FILES_TO_DOWNLOAD } from "./utils/vencordLoader";
|
import { isValidVencordInstall } from "./utils/vencordLoader";
|
||||||
|
|
||||||
ipcMain.on(IpcEvents.GET_VENCORD_PRELOAD_FILE, e => {
|
ipcMain.on(IpcEvents.GET_VENCORD_PRELOAD_FILE, e => {
|
||||||
e.returnValue = join(VENCORD_FILES_DIR, "vencordDesktopPreload.js");
|
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";
|
if (!res.filePaths.length) return "cancelled";
|
||||||
|
|
||||||
const dir = res.filePaths[0];
|
const dir = res.filePaths[0];
|
||||||
for (const file of FILES_TO_DOWNLOAD) {
|
if (!isValidVencordInstall(dir)) return "invalid";
|
||||||
if (!existsSync(join(dir, file))) return "invalid";
|
|
||||||
}
|
|
||||||
|
|
||||||
return dir;
|
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() {
|
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 });
|
mkdirSync(VENCORD_FILES_DIR, { recursive: true });
|
||||||
|
|
||||||
await downloadVencordFiles();
|
await downloadVencordFiles();
|
||||||
|
|
Loading…
Add table
Reference in a new issue