feat: pass hydra-httpdl binary path to HttpDownloader

This commit is contained in:
Hachi-R
2025-04-10 16:40:40 -03:00
parent a0ef59a13c
commit 8e01142225
3 changed files with 10 additions and 5 deletions

View File

@@ -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

View File

@@ -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))

View File

@@ -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) {