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