From cc5967814b9d4b01ce333e380ce47a30b8d35ab9 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Mon, 16 Sep 2024 14:07:00 -0300 Subject: [PATCH] fix: adjust when calling /games/download --- src/main/events/torrenting/start-game-download.ts | 13 ++++++++++++- src/main/services/library-sync/create-game.ts | 12 ------------ 2 files changed, 12 insertions(+), 13 deletions(-) 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),