fix: bug after pause seed

This commit is contained in:
Zamitto 2024-12-23 09:38:50 -03:00
parent c9be6b6b92
commit 56217fbcf8
3 changed files with 14 additions and 14 deletions

View File

@ -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,

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

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