mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: implement seed process initiation in PythonRPC
This commit is contained in:
parent
09ea3b27f4
commit
5714c23073
2 changed files with 27 additions and 0 deletions
|
@ -8,6 +8,7 @@ import crypto from "node:crypto";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger";
|
||||||
import { Readable } from "node:stream";
|
import { Readable } from "node:stream";
|
||||||
import { app, dialog } from "electron";
|
import { app, dialog } from "electron";
|
||||||
|
import { startSeedProcess } from "./seed";
|
||||||
|
|
||||||
const binaryNameByPlatform: Partial<Record<NodeJS.Platform, string>> = {
|
const binaryNameByPlatform: Partial<Record<NodeJS.Platform, string>> = {
|
||||||
darwin: "hydra-python-rpc",
|
darwin: "hydra-python-rpc",
|
||||||
|
@ -83,6 +84,8 @@ export class PythonRPC {
|
||||||
this.logStderr(childProcess.stderr);
|
this.logStderr(childProcess.stderr);
|
||||||
|
|
||||||
this.pythonProcess = childProcess;
|
this.pythonProcess = childProcess;
|
||||||
|
|
||||||
|
startSeedProcess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
24
src/main/services/seed.ts
Normal file
24
src/main/services/seed.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import { gameRepository } from "@main/repository";
|
||||||
|
import { DownloadManager } from "./download/download-manager";
|
||||||
|
import { sleep } from "@main/helpers";
|
||||||
|
|
||||||
|
export const startSeedProcess = async () => {
|
||||||
|
const seedList = await gameRepository.find({
|
||||||
|
where: {
|
||||||
|
shouldSeed: true,
|
||||||
|
downloader: 1,
|
||||||
|
progress: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (seedList.length === 0) return;
|
||||||
|
|
||||||
|
await sleep(1000);
|
||||||
|
// wait for python process to start
|
||||||
|
|
||||||
|
seedList.map(async (game) => {
|
||||||
|
await DownloadManager.startDownload(game);
|
||||||
|
await sleep(100);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue