mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: add initial download handling in Python RPC and update spawn method to accept download parameters
This commit is contained in:
parent
35d14b33ca
commit
e463ee569a
3 changed files with 43 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
|||
import { DownloadManager, Ludusavi, startMainLoop } from "./services";
|
||||
import { Ludusavi, startMainLoop } from "./services";
|
||||
import {
|
||||
downloadQueueRepository,
|
||||
userPreferencesRepository,
|
||||
|
@ -10,7 +10,6 @@ import { uploadGamesBatch } from "./services/library-sync";
|
|||
import { PythonRPC } from "./services/python-rpc";
|
||||
import { Aria2 } from "./services/aria2";
|
||||
import { startSeedProcess } from "./services/seed";
|
||||
import { sleep } from "./helpers";
|
||||
|
||||
const loadState = async (userPreferences: UserPreferences | null) => {
|
||||
import("./events");
|
||||
|
@ -36,12 +35,19 @@ const loadState = async (userPreferences: UserPreferences | null) => {
|
|||
},
|
||||
});
|
||||
|
||||
PythonRPC.spawn();
|
||||
await sleep(1000);
|
||||
// wait for python process to start
|
||||
|
||||
if (nextQueueItem?.game.status === "active") {
|
||||
DownloadManager.startDownload(nextQueueItem.game);
|
||||
if (
|
||||
nextQueueItem?.game.status === "active" &&
|
||||
nextQueueItem?.game.id &&
|
||||
nextQueueItem?.game.uri &&
|
||||
nextQueueItem?.game.downloadPath
|
||||
) {
|
||||
PythonRPC.spawn({
|
||||
game_id: nextQueueItem.game.id,
|
||||
url: nextQueueItem.game.uri,
|
||||
save_path: nextQueueItem.game.downloadPath,
|
||||
});
|
||||
} else {
|
||||
PythonRPC.spawn();
|
||||
}
|
||||
|
||||
await startSeedProcess();
|
||||
|
|
|
@ -9,6 +9,12 @@ import { logger } from "./logger";
|
|||
import { Readable } from "node:stream";
|
||||
import { app, dialog } from "electron";
|
||||
|
||||
interface StartDownloadPayload {
|
||||
game_id: number;
|
||||
url: string;
|
||||
save_path: string;
|
||||
}
|
||||
|
||||
const binaryNameByPlatform: Partial<Record<NodeJS.Platform, string>> = {
|
||||
darwin: "hydra-python-rpc",
|
||||
linux: "hydra-python-rpc",
|
||||
|
@ -36,9 +42,15 @@ export class PythonRPC {
|
|||
readable.on("data", logger.log);
|
||||
}
|
||||
|
||||
public static spawn() {
|
||||
public static spawn(initialDownload?: StartDownloadPayload) {
|
||||
console.log([this.BITTORRENT_PORT, this.RPC_PORT, this.RPC_PASSWORD]);
|
||||
const commonArgs = [this.BITTORRENT_PORT, this.RPC_PORT, this.RPC_PASSWORD];
|
||||
|
||||
const commonArgs = [
|
||||
this.BITTORRENT_PORT,
|
||||
this.RPC_PORT,
|
||||
this.RPC_PASSWORD,
|
||||
initialDownload ? JSON.stringify(initialDownload) : "",
|
||||
];
|
||||
|
||||
if (app.isPackaged) {
|
||||
const binaryName = binaryNameByPlatform[process.platform]!;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue