Skip to content

Commit

Permalink
fix: now it allows paths with space
Browse files Browse the repository at this point in the history
  • Loading branch information
3Shain committed Mar 6, 2023
1 parent 69e4afd commit 5954b08
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
]);
Expand Down
12 changes: 10 additions & 2 deletions src/common-update-ui.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.`);
Expand All @@ -26,6 +27,7 @@ if (typeof Neutralino == "undefined") {
`Launcher failed to open\n${e}\n${e.stack}`,
"OK"
);
await shutdown();
Neutralino.app.exit(-1);
});
}
8 changes: 4 additions & 4 deletions src/utils/neu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function exec(
command: string,
args: string[]
): Promise<Neutralino.os.ExecCommandResult> {
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(
Expand All @@ -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 + "");
Expand Down Expand Up @@ -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)}"`,
]);
}

Expand Down

0 comments on commit 5954b08

Please sign in to comment.