detect if installation is portable for persistent vesktop settings
This commit is contained in:
parent
d11a9a04ff
commit
08969a9138
2 changed files with 10 additions and 5 deletions
|
@ -6,10 +6,16 @@
|
||||||
|
|
||||||
import { app } from "electron";
|
import { app } from "electron";
|
||||||
import { existsSync, readdirSync, renameSync, rmdirSync } from "fs";
|
import { existsSync, readdirSync, renameSync, rmdirSync } from "fs";
|
||||||
import { join } from "path";
|
import { join, resolve } from "path";
|
||||||
|
|
||||||
|
const vesktopDir = resolve("..", "..", "..", "..", __dirname);
|
||||||
|
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 = process.env.VENCORD_USER_DATA_DIR || join(app.getPath("userData"));
|
export const DATA_DIR = PORTABLE
|
||||||
|
? resolve(vesktopDir + "Data")
|
||||||
|
: process.env.VENCORD_USER_DATA_DIR || join(app.getPath("userData"));
|
||||||
|
|
||||||
// TODO: remove eventually
|
// TODO: remove eventually
|
||||||
if (existsSync(LEGACY_DATA_DIR)) {
|
if (existsSync(LEGACY_DATA_DIR)) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { app, BrowserWindow, shell } from "electron";
|
import { app, BrowserWindow, shell } from "electron";
|
||||||
|
import { PORTABLE } from "main/constants";
|
||||||
import { Settings, State } from "main/settings";
|
import { Settings, State } from "main/settings";
|
||||||
import { handle } from "main/utils/ipcWrappers";
|
import { handle } from "main/utils/ipcWrappers";
|
||||||
import { makeLinksOpenExternally } from "main/utils/makeLinksOpenExternally";
|
import { makeLinksOpenExternally } from "main/utils/makeLinksOpenExternally";
|
||||||
|
@ -23,8 +24,6 @@ let updateData: UpdateData;
|
||||||
|
|
||||||
handle(IpcEvents.UPDATER_GET_DATA, () => updateData);
|
handle(IpcEvents.UPDATER_GET_DATA, () => updateData);
|
||||||
handle(IpcEvents.UPDATER_DOWNLOAD, () => {
|
handle(IpcEvents.UPDATER_DOWNLOAD, () => {
|
||||||
const portable = !!process.env.PORTABLE_EXECUTABLE_FILE;
|
|
||||||
|
|
||||||
const { assets } = updateData.release;
|
const { assets } = updateData.release;
|
||||||
const url = (() => {
|
const url = (() => {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
|
@ -33,7 +32,7 @@ handle(IpcEvents.UPDATER_DOWNLOAD, () => {
|
||||||
if (!a.name.endsWith(".exe")) return false;
|
if (!a.name.endsWith(".exe")) return false;
|
||||||
|
|
||||||
const isSetup = a.name.includes("Setup");
|
const isSetup = a.name.includes("Setup");
|
||||||
return portable ? !isSetup : isSetup;
|
return PORTABLE ? !isSetup : isSetup;
|
||||||
})!.browser_download_url;
|
})!.browser_download_url;
|
||||||
case "darwin":
|
case "darwin":
|
||||||
return assets.find(a =>
|
return assets.find(a =>
|
||||||
|
|
Reference in a new issue