diff --git a/src/main/events/torrenting/start-game-download.ts b/src/main/events/torrenting/start-game-download.ts index a24e0ffb..253ab159 100644 --- a/src/main/events/torrenting/start-game-download.ts +++ b/src/main/events/torrenting/start-game-download.ts @@ -2,7 +2,7 @@ import { registerEvent } from "../register-event"; import type { StartGameDownloadPayload } from "@types"; import { getFileBase64 } from "@main/helpers"; -import { DownloadManager } from "@main/services"; +import { DownloadManager, HydraApi, logger } from "@main/services"; import { Not } from "typeorm"; import { steamGamesWorker } from "@main/workers"; @@ -101,6 +101,17 @@ const startGameDownload = async ( createGame(updatedGame!).catch(() => {}); + HydraApi.post( + "/games/download", + { + objectId: updatedGame!.objectID, + shop: updatedGame!.shop, + }, + { needsAuth: false } + ).catch((err) => { + logger.error("Failed to create game download", err); + }); + await DownloadManager.cancelDownload(updatedGame!.id); await DownloadManager.startDownload(updatedGame!); diff --git a/src/main/services/library-sync/create-game.ts b/src/main/services/library-sync/create-game.ts index 396ddbdd..6c701c9a 100644 --- a/src/main/services/library-sync/create-game.ts +++ b/src/main/services/library-sync/create-game.ts @@ -1,20 +1,8 @@ import { Game } from "@main/entity"; import { HydraApi } from "../hydra-api"; import { gameRepository } from "@main/repository"; -import { logger } from "../logger"; export const createGame = async (game: Game) => { - HydraApi.post( - "/games/download", - { - objectId: game.objectID, - shop: game.shop, - }, - { needsAuth: false } - ).catch((err) => { - logger.error("Failed to create game download", err); - }); - return HydraApi.post(`/profile/games`, { objectId: game.objectID, playTimeInMilliseconds: Math.trunc(game.playTimeInMilliseconds),