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,
|
shop: GameShop,
|
||||||
objectId: string
|
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;
|
if (!download) return;
|
||||||
|
|
||||||
await downloadsSublevel.put(levelKeys.game(shop, objectId), {
|
await downloadsSublevel.put(downloadKey, {
|
||||||
...download,
|
...download,
|
||||||
status: "seeding",
|
status: "seeding",
|
||||||
shouldSeed: true,
|
shouldSeed: true,
|
||||||
|
|
|
@ -57,23 +57,21 @@ export const loadState = async () => {
|
||||||
.values()
|
.values()
|
||||||
.all()
|
.all()
|
||||||
.then((games) => {
|
.then((games) => {
|
||||||
return sortBy(
|
return sortBy(games, "timestamp", "DESC");
|
||||||
games.filter((game) => game.queued),
|
|
||||||
"timestamp",
|
|
||||||
"DESC"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [nextItemOnQueue] = downloads;
|
const [nextItemOnQueue] = downloads.filter((game) => game.queued);
|
||||||
|
|
||||||
const downloadsToSeed = downloads.filter(
|
const downloadsToSeed = downloads.filter(
|
||||||
(download) =>
|
(game) =>
|
||||||
download.shouldSeed &&
|
game.shouldSeed &&
|
||||||
download.downloader === Downloader.Torrent &&
|
game.downloader === Downloader.Torrent &&
|
||||||
download.progress === 1 &&
|
game.progress === 1 &&
|
||||||
download.uri !== null
|
game.uri !== null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log("downloadsToSeed", downloadsToSeed);
|
||||||
|
|
||||||
await DownloadManager.startRPC(nextItemOnQueue, downloadsToSeed);
|
await DownloadManager.startRPC(nextItemOnQueue, downloadsToSeed);
|
||||||
|
|
||||||
startMainLoop();
|
startMainLoop();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue