add portable data dir for portable installs, patched updater

This commit is contained in:
Mr.Garlic 2024-05-08 16:04:00 +01:00
parent 08969a9138
commit b10d77659b
3 changed files with 9 additions and 8 deletions

View file

@ -8,12 +8,12 @@ import { app } from "electron";
import { existsSync, readdirSync, renameSync, rmdirSync } from "fs"; import { existsSync, readdirSync, renameSync, rmdirSync } from "fs";
import { join, resolve } from "path"; import { join, resolve } from "path";
const vesktopDir = resolve("..", "..", "..", "..", __dirname); const vesktopDir = resolve(__dirname, "..", "..", "..", "..");
export const PORTABLE = process.platform === "win32" && !readdirSync(vesktopDir).includes("Uninstall Vesktop.exe"); export const PORTABLE = process.platform === "win32" && !readdirSync(vesktopDir).includes("Uninstall Vesktop.exe");
const LEGACY_DATA_DIR = join(app.getPath("appData"), "VencordDesktop", "VencordDesktop"); const LEGACY_DATA_DIR = join(app.getPath("appData"), "VencordDesktop", "VencordDesktop");
export const DATA_DIR = PORTABLE export const DATA_DIR = PORTABLE
? resolve(vesktopDir + "Data") ? join(vesktopDir, "Data")
: process.env.VENCORD_USER_DATA_DIR || join(app.getPath("userData")); : process.env.VENCORD_USER_DATA_DIR || join(app.getPath("userData"));
// TODO: remove eventually // TODO: remove eventually

View file

@ -6,13 +6,13 @@
import { app } from "electron"; import { app } from "electron";
import { BrowserWindow } from "electron/main"; import { BrowserWindow } from "electron/main";
import { copyFileSync, mkdirSync, readdirSync } from "fs"; import { copyFileSync, mkdirSync, readdirSync, existsSync } from "fs";
import { join } from "path"; import { join } from "path";
import { SplashProps } from "shared/browserWinProperties"; import { SplashProps } from "shared/browserWinProperties";
import { ICON_PATH, VIEW_DIR } from "shared/paths"; import { ICON_PATH, VIEW_DIR } from "shared/paths";
import { autoStart } from "./autoStart"; import { autoStart } from "./autoStart";
import { DATA_DIR } from "./constants"; import { DATA_DIR, PORTABLE } from "./constants";
import { createWindows } from "./mainWindow"; import { createWindows } from "./mainWindow";
import { Settings, State } from "./settings"; import { Settings, State } from "./settings";
import { makeLinksOpenExternally } from "./utils/makeLinksOpenExternally"; import { makeLinksOpenExternally } from "./utils/makeLinksOpenExternally";
@ -37,6 +37,8 @@ export function createFirstLaunchTour() {
makeLinksOpenExternally(win); makeLinksOpenExternally(win);
if (PORTABLE && !existsSync(DATA_DIR)) mkdirSync(DATA_DIR);
win.loadFile(join(VIEW_DIR, "first-launch.html")); win.loadFile(join(VIEW_DIR, "first-launch.html"));
win.webContents.addListener("console-message", (_e, _l, msg) => { win.webContents.addListener("console-message", (_e, _l, msg) => {
if (msg === "cancel") return app.exit(); if (msg === "cancel") return app.exit();

View file

@ -28,11 +28,10 @@ handle(IpcEvents.UPDATER_DOWNLOAD, () => {
const url = (() => { const url = (() => {
switch (process.platform) { switch (process.platform) {
case "win32": case "win32":
console.log(assets);
return assets.find(a => { return assets.find(a => {
if (!a.name.endsWith(".exe")) return false; if (PORTABLE && a.name.endsWith("win.zip")) return true;
if (!PORTABLE && a.name.endsWith(".exe")) return true;
const isSetup = a.name.includes("Setup");
return PORTABLE ? !isSetup : isSetup;
})!.browser_download_url; })!.browser_download_url;
case "darwin": case "darwin":
return assets.find(a => return assets.find(a =>