Merge branch 'feature/seed-completed-downloads' into feat/achievements-points

This commit is contained in:
Zamitto 2024-12-23 09:39:08 -03:00
commit 2b44728c0e
8 changed files with 20 additions and 24 deletions

View File

@ -59,11 +59,14 @@ 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({

View File

@ -89,7 +89,7 @@ const uploadSaveGame = async (
"Content-Type": "application/tar",
},
onUploadProgress: (progressEvent) => {
console.log(progressEvent);
logger.log(progressEvent);
},
});

View File

@ -22,8 +22,6 @@ export class Aria2 {
],
{ stdio: "inherit", windowsHide: true }
);
console.log(this.process);
}
public static kill() {

View File

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

View File

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

View File

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

View File

@ -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"],
});

View File

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