add portable data dir for portable installs, patched updater
This commit is contained in:
		
							parent
							
								
									08969a9138
								
							
						
					
					
						commit
						b10d77659b
					
				
					 3 changed files with 9 additions and 8 deletions
				
			
		|  | @ -8,12 +8,12 @@ import { app } from "electron"; | |||
| import { existsSync, readdirSync, renameSync, rmdirSync } from "fs"; | ||||
| 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"); | ||||
| 
 | ||||
| const LEGACY_DATA_DIR = join(app.getPath("appData"), "VencordDesktop", "VencordDesktop"); | ||||
| export const DATA_DIR = PORTABLE | ||||
|     ? resolve(vesktopDir + "Data") | ||||
|     ? join(vesktopDir, "Data") | ||||
|     : process.env.VENCORD_USER_DATA_DIR || join(app.getPath("userData")); | ||||
| 
 | ||||
| // TODO: remove eventually
 | ||||
|  |  | |||
|  | @ -6,13 +6,13 @@ | |||
| 
 | ||||
| import { app } from "electron"; | ||||
| import { BrowserWindow } from "electron/main"; | ||||
| import { copyFileSync, mkdirSync, readdirSync } from "fs"; | ||||
| import { copyFileSync, mkdirSync, readdirSync, existsSync } from "fs"; | ||||
| import { join } from "path"; | ||||
| import { SplashProps } from "shared/browserWinProperties"; | ||||
| import { ICON_PATH, VIEW_DIR } from "shared/paths"; | ||||
| 
 | ||||
| import { autoStart } from "./autoStart"; | ||||
| import { DATA_DIR } from "./constants"; | ||||
| import { DATA_DIR, PORTABLE } from "./constants"; | ||||
| import { createWindows } from "./mainWindow"; | ||||
| import { Settings, State } from "./settings"; | ||||
| import { makeLinksOpenExternally } from "./utils/makeLinksOpenExternally"; | ||||
|  | @ -37,6 +37,8 @@ export function createFirstLaunchTour() { | |||
| 
 | ||||
|     makeLinksOpenExternally(win); | ||||
| 
 | ||||
|     if (PORTABLE && !existsSync(DATA_DIR)) mkdirSync(DATA_DIR); | ||||
| 
 | ||||
|     win.loadFile(join(VIEW_DIR, "first-launch.html")); | ||||
|     win.webContents.addListener("console-message", (_e, _l, msg) => { | ||||
|         if (msg === "cancel") return app.exit(); | ||||
|  |  | |||
|  | @ -28,11 +28,10 @@ handle(IpcEvents.UPDATER_DOWNLOAD, () => { | |||
|     const url = (() => { | ||||
|         switch (process.platform) { | ||||
|             case "win32": | ||||
|                 console.log(assets); | ||||
|                 return assets.find(a => { | ||||
|                     if (!a.name.endsWith(".exe")) return false; | ||||
| 
 | ||||
|                     const isSetup = a.name.includes("Setup"); | ||||
|                     return PORTABLE ? !isSetup : isSetup; | ||||
|                     if (PORTABLE && a.name.endsWith("win.zip")) return true; | ||||
|                     if (!PORTABLE && a.name.endsWith(".exe")) return true; | ||||
|                 })!.browser_download_url; | ||||
|             case "darwin": | ||||
|                 return assets.find(a => | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Mr.Garlic
						Mr.Garlic