mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
fix: improve download and seeding logic in main process
This commit is contained in:
parent
5574f6cb20
commit
0e88300747
2 changed files with 12 additions and 13 deletions
|
@ -8,11 +8,12 @@ const resumeGameSeed = async (
|
|||
shop: GameShop,
|
||||
objectId: string
|
||||
) => {
|
||||
const download = await downloadsSublevel.get(levelKeys.game(shop, objectId));
|
||||
const downloadKey = levelKeys.game(shop, objectId);
|
||||
const download = await downloadsSublevel.get(downloadKey);
|
||||
|
||||
if (!download) return;
|
||||
|
||||
await downloadsSublevel.put(levelKeys.game(shop, objectId), {
|
||||
await downloadsSublevel.put(downloadKey, {
|
||||
...download,
|
||||
status: "seeding",
|
||||
shouldSeed: true,
|
||||
|
|
|
@ -57,23 +57,21 @@ export const loadState = async () => {
|
|||
.values()
|
||||
.all()
|
||||
.then((games) => {
|
||||
return sortBy(
|
||||
games.filter((game) => game.queued),
|
||||
"timestamp",
|
||||
"DESC"
|
||||
);
|
||||
return sortBy(games, "timestamp", "DESC");
|
||||
});
|
||||
|
||||
const [nextItemOnQueue] = downloads;
|
||||
const [nextItemOnQueue] = downloads.filter((game) => game.queued);
|
||||
|
||||
const downloadsToSeed = downloads.filter(
|
||||
(download) =>
|
||||
download.shouldSeed &&
|
||||
download.downloader === Downloader.Torrent &&
|
||||
download.progress === 1 &&
|
||||
download.uri !== null
|
||||
(game) =>
|
||||
game.shouldSeed &&
|
||||
game.downloader === Downloader.Torrent &&
|
||||
game.progress === 1 &&
|
||||
game.uri !== null
|
||||
);
|
||||
|
||||
console.log("downloadsToSeed", downloadsToSeed);
|
||||
|
||||
await DownloadManager.startRPC(nextItemOnQueue, downloadsToSeed);
|
||||
|
||||
startMainLoop();
|
||||
|
|
Loading…
Add table
Reference in a new issue