mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-19 09:13:57 +00:00
34 lines
764 B
TypeScript
34 lines
764 B
TypeScript
import path from "node:path";
|
|
import cp from "node:child_process";
|
|
import { app } from "electron";
|
|
|
|
export class Aria2 {
|
|
private static process: cp.ChildProcess | null = null;
|
|
private static readonly binaryPath = app.isPackaged
|
|
? path.join(process.resourcesPath, "aria2", "aria2c")
|
|
: path.join(__dirname, "..", "..", "aria2", "aria2c");
|
|
|
|
public static spawn() {
|
|
this.process = cp.spawn(
|
|
this.binaryPath,
|
|
[
|
|
"--enable-rpc",
|
|
"--rpc-listen-all",
|
|
"--file-allocation=none",
|
|
"--allow-overwrite=true",
|
|
"-s",
|
|
"16",
|
|
"-x",
|
|
"16",
|
|
"-k",
|
|
"1M",
|
|
],
|
|
{ stdio: "inherit", windowsHide: true }
|
|
);
|
|
}
|
|
|
|
public static kill() {
|
|
this.process?.kill();
|
|
}
|
|
}
|