Skip to content

Commit

Permalink
fix: bug after pause seed
Browse files Browse the repository at this point in the history
  • Loading branch information
zamitto committed Dec 23, 2024
1 parent c9be6b6 commit 56217fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
7 changes: 5 additions & 2 deletions python_rpc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 7 additions & 9 deletions src/main/services/download/download-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
});
Expand All @@ -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() {
Expand Down
5 changes: 2 additions & 3 deletions src/renderer/src/pages/downloads/download-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down

0 comments on commit 56217fb

Please sign in to comment.