mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-02 16:23:48 +03:00
Merge branch 'feature/seed-completed-downloads' into feat/achievements-points
This commit is contained in:
commit
2b44728c0e
@ -59,12 +59,15 @@ def seed_status():
|
||||
return auth_error
|
||||
|
||||
seed_status = []
|
||||
|
||||
for game_id, downloader in downloads.items():
|
||||
if not downloader:
|
||||
continue
|
||||
|
||||
|
||||
response = downloader.get_download_status()
|
||||
|
||||
if response is None:
|
||||
continue
|
||||
|
||||
if response.get('status') == 5:
|
||||
seed_status.append({
|
||||
'gameId': game_id,
|
||||
|
@ -89,7 +89,7 @@ const uploadSaveGame = async (
|
||||
"Content-Type": "application/tar",
|
||||
},
|
||||
onUploadProgress: (progressEvent) => {
|
||||
console.log(progressEvent);
|
||||
logger.log(progressEvent);
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -22,8 +22,6 @@ export class Aria2 {
|
||||
],
|
||||
{ stdio: "inherit", windowsHide: true }
|
||||
);
|
||||
|
||||
console.log(this.process);
|
||||
}
|
||||
|
||||
public static kill() {
|
||||
|
@ -158,13 +158,14 @@ export class DownloadManager {
|
||||
}
|
||||
|
||||
public static async getSeedStatus() {
|
||||
const seedStatus = await PythonRPC.rpc.get<LibtorrentPayload[] | []>(
|
||||
"/seed-status"
|
||||
);
|
||||
const seedStatus = await PythonRPC.rpc
|
||||
.get<LibtorrentPayload[] | []>("/seed-status")
|
||||
.then((res) => res.data);
|
||||
|
||||
if (!seedStatus.data.length) return;
|
||||
console.log(seedStatus);
|
||||
if (!seedStatus.length) return;
|
||||
|
||||
seedStatus.data.forEach(async (status) => {
|
||||
seedStatus.forEach(async (status) => {
|
||||
const game = await gameRepository.findOne({
|
||||
where: { id: status.gameId },
|
||||
});
|
||||
@ -188,10 +189,7 @@ export class DownloadManager {
|
||||
}
|
||||
});
|
||||
|
||||
WindowManager.mainWindow?.webContents.send(
|
||||
"on-seeding-status",
|
||||
JSON.parse(JSON.stringify(seedStatus.data))
|
||||
);
|
||||
WindowManager.mainWindow?.webContents.send("on-seeding-status", seedStatus);
|
||||
}
|
||||
|
||||
static async pauseDownload() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import path from "node:path";
|
||||
import fs from "node:fs";
|
||||
import { logger } from "../logger";
|
||||
|
||||
export const calculateETA = (
|
||||
totalLength: number,
|
||||
@ -33,7 +34,7 @@ export const getDirSize = async (dir: string): Promise<number> => {
|
||||
|
||||
return sizes.reduce((total, size) => total + size, 0);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
logger.error(error);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
@ -6,6 +6,7 @@ import type {
|
||||
TorBoxAddTorrentRequest,
|
||||
TorBoxRequestLinkRequest,
|
||||
} from "@types";
|
||||
import { logger } from "../logger";
|
||||
|
||||
export class TorBoxClient {
|
||||
private static instance: AxiosInstance;
|
||||
@ -65,8 +66,8 @@ export class TorBoxClient {
|
||||
);
|
||||
|
||||
if (response.status !== 200) {
|
||||
console.error(response.data.error);
|
||||
console.error(response.data.detail);
|
||||
logger.error(response.data.error);
|
||||
logger.error(response.data.detail);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,6 @@ export class PythonRPC {
|
||||
}
|
||||
|
||||
public static spawn(initialDownload?: StartDownloadPayload) {
|
||||
console.log([this.BITTORRENT_PORT, this.RPC_PORT, this.RPC_PASSWORD]);
|
||||
|
||||
const commonArgs = [
|
||||
this.BITTORRENT_PORT,
|
||||
this.RPC_PORT,
|
||||
@ -86,8 +84,6 @@ export class PythonRPC {
|
||||
"main.py"
|
||||
);
|
||||
|
||||
console.log(scriptPath);
|
||||
|
||||
const childProcess = cp.spawn("python3", [scriptPath, ...commonArgs], {
|
||||
stdio: ["inherit", "inherit"],
|
||||
});
|
||||
|
@ -77,13 +77,12 @@ export function DownloadGroup({
|
||||
};
|
||||
|
||||
const seedingMap = useMemo(() => {
|
||||
if (!Array.isArray(seedingStatus) || seedingStatus.length === 0) {
|
||||
return new Map<number, SeedingStatus>();
|
||||
}
|
||||
const map = new Map<number, SeedingStatus>();
|
||||
|
||||
seedingStatus.forEach((seed) => {
|
||||
map.set(seed.gameId, seed);
|
||||
});
|
||||
|
||||
return map;
|
||||
}, [seedingStatus]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user