diff --git a/python_rpc/http_downloader.py b/python_rpc/http_downloader.py index 4a71607c..3d89b2a0 100644 --- a/python_rpc/http_downloader.py +++ b/python_rpc/http_downloader.py @@ -3,9 +3,8 @@ import subprocess import json class HttpDownloader: - def __init__(self): - self.binaries_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "binaries") - self.hydra_exe = os.path.join(self.binaries_path, "hydra-httpdl.exe") + def __init__(self, hydra_httpdl_bin: str): + self.hydra_exe = hydra_httpdl_bin self.process = None self.last_status = None diff --git a/python_rpc/main.py b/python_rpc/main.py index 915f1670..bc108a33 100644 --- a/python_rpc/main.py +++ b/python_rpc/main.py @@ -13,6 +13,7 @@ http_port = sys.argv[2] rpc_password = sys.argv[3] start_download_payload = sys.argv[4] start_seeding_payload = sys.argv[5] +hydra_httpdl_bin = sys.argv[6] downloads = {} # This can be streamed down from Node @@ -32,7 +33,7 @@ if start_download_payload: except Exception as e: print("Error starting torrent download", e) else: - http_downloader = HttpDownloader() + http_downloader = HttpDownloader(hydra_httpdl_bin) downloads[initial_download['game_id']] = http_downloader try: http_downloader.start_download(initial_download['url'], initial_download['save_path'], initial_download.get('header'), initial_download.get("out")) @@ -149,7 +150,7 @@ def action(): if existing_downloader and isinstance(existing_downloader, HttpDownloader): existing_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'), data.get('allow_multiple_connections', False)) else: - http_downloader = HttpDownloader() + http_downloader = HttpDownloader(hydra_httpdl_bin) downloads[game_id] = http_downloader http_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'), data.get('allow_multiple_connections', False)) diff --git a/src/main/services/python-rpc.ts b/src/main/services/python-rpc.ts index 22e60461..4ffbfd64 100644 --- a/src/main/services/python-rpc.ts +++ b/src/main/services/python-rpc.ts @@ -26,6 +26,10 @@ export class PythonRPC { public static readonly RPC_PORT = "8084"; private static readonly RPC_PASSWORD = crypto.randomBytes(32).toString("hex"); + private static readonly binaryPath = app.isPackaged + ? path.join(process.resourcesPath, "binaries", "hydra-httpdl.exe") + : path.join(__dirname, "..", "..", "binaries", "hydra-httpdl.exe"); + private static pythonProcess: cp.ChildProcess | null = null; public static readonly rpc = axios.create({ @@ -52,6 +56,7 @@ export class PythonRPC { this.RPC_PASSWORD, initialDownload ? JSON.stringify(initialDownload) : "", initialSeeding ? JSON.stringify(initialSeeding) : "", + this.binaryPath, ]; if (app.isPackaged) {