From 5954b08c5bb264d72fed4fade3d8ffd2bf6d6eef Mon Sep 17 00:00:00 2001 From: 3Shain Date: Mon, 6 Mar 2023 21:27:04 +0000 Subject: [PATCH] fix: now it allows paths with space --- build-app.js | 2 +- src/app.tsx | 4 ++-- src/common-update-ui.tsx | 12 ++++++++++-- src/index.tsx | 2 ++ src/utils/neu.ts | 8 ++++---- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/build-app.js b/build-app.js index 9af1d17..3ee0959 100644 --- a/build-app.js +++ b/build-app.js @@ -132,7 +132,7 @@ echo $APST_DIR mkdir -p "$APST_DIR" CONTENTS_DIR="$(dirname "$SCRIPT_DIR")" rsync -rlptu "$CONTENTS_DIR/Resources/." "$APST_DIR" -exec "$SCRIPT_DIR/${appname}" --path="$APST_DIR"` +PATH_LAUNCH="$(dirname "$CONTENTS_DIR")" exec "$SCRIPT_DIR/${appname}" --path="$APST_DIR"` ); await fs.chmod( diff --git a/src/app.tsx b/src/app.tsx index dec3667..68a77c2 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -43,9 +43,9 @@ export async function createApp() { `--rpc-allow-origin-all`, // `-c`, `--input-file`, - `${aria2_session}`, + `"${aria2_session}"`, `--save-session`, - `${aria2_session}`, + `"${aria2_session}"`, `--pause`, `true`, ]); diff --git a/src/common-update-ui.tsx b/src/common-update-ui.tsx index 800573c..ec81213 100644 --- a/src/common-update-ui.tsx +++ b/src/common-update-ui.tsx @@ -1,7 +1,7 @@ import { Button, Progress, ProgressIndicator, Center } from "@hope-ui/solid"; import { Box, VStack } from "@hope-ui/solid"; import { createSignal, onMount, Show } from "solid-js"; -import { fatal, log, shutdown } from "./utils"; +import { fatal, log, shutdown, wait } from "./utils"; export function createCommonUpdateUI(program: () => CommonUpdateProgram) { let confirmRestart: (v: any) => void; @@ -31,7 +31,15 @@ export function createCommonUpdateUI(program: () => CommonUpdateProgram) { setDone(true); await confirmRestartPromise; await shutdown(); - Neutralino.app.restartProcess(); + // await wait(1000); + // HACK + if(import.meta.env.PROD) { + const app = await Neutralino.os.getEnv("PATH_LAUNCH"); + await Neutralino.os.execCommand(`open "${app}"`, {background:true}); + Neutralino.app.exit(0); + } else { + Neutralino.app.restartProcess(); + } })() .then() .catch(fatal); diff --git a/src/index.tsx b/src/index.tsx index e081dd0..52a3f95 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,6 +3,7 @@ import { createApp } from "./app"; import { HopeProvider } from "@hope-ui/solid"; import "./styles.css"; +import { shutdown } from "./utils"; if (typeof Neutralino == "undefined") { console.log(`This app doesn't work on browser.`); @@ -26,6 +27,7 @@ if (typeof Neutralino == "undefined") { `Launcher failed to open\n${e}\n${e.stack}`, "OK" ); + await shutdown(); Neutralino.app.exit(-1); }); } diff --git a/src/utils/neu.ts b/src/utils/neu.ts index bd0aa56..30725e9 100644 --- a/src/utils/neu.ts +++ b/src/utils/neu.ts @@ -15,7 +15,7 @@ export async function exec( command: string, args: string[] ): Promise { - const cmd = `${await resolve(command)} ${args.join(" ")}`; + const cmd = `"${await resolve(command)}" ${args.join(" ")}`; const ret = await Neutralino.os.execCommand(cmd, {}); if (ret.exitCode != 0) { throw new Error( @@ -30,7 +30,7 @@ export function tar_extract(src: string, dst: string) { } export async function spawn(command: string, args: string[]) { - const cmd = `${await resolve(command)} ${args.join(" ")}`; + const cmd = `"${await resolve(command)}" ${args.join(" ")}`; const { pid } = await Neutralino.os.spawnProcess(cmd); // await Neutralino.os. await log(pid + ""); @@ -74,8 +74,8 @@ export async function appendFile(path: string, content: string) { export async function forceMove(source: string, destination: string) { return await exec("mv", [ "-f", - await resolve(source), - await resolve(destination), + `"${await resolve(source)}"`, + `"${await resolve(destination)}"`, ]); }