From 0398164906f6d95174720d2c09fbadcabe582c0e Mon Sep 17 00:00:00 2001 From: lilezek Date: Mon, 6 May 2024 11:15:49 +0200 Subject: [PATCH] fix: do not notify about the download being ready until the parts are built into the single file. --- .../downloaders/real-debrid.downloader.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/services/downloaders/real-debrid.downloader.ts b/src/main/services/downloaders/real-debrid.downloader.ts index ed81ab21..2b283e2f 100644 --- a/src/main/services/downloaders/real-debrid.downloader.ts +++ b/src/main/services/downloaders/real-debrid.downloader.ts @@ -47,11 +47,8 @@ export class RealDebridDownloader extends Downloader { this.download.on("progress", async ({ total }) => { const updatePayload: QueryDeepPartialEntity = { - status: - total.percentage === 100 - ? GameStatus.Finished - : GameStatus.Downloading, - progress: total.percentage / 100, + status: GameStatus.Downloading, + progress: Math.min(0.99, total.percentage / 100), bytesDownloaded: total.bytes, }; @@ -62,6 +59,17 @@ export class RealDebridDownloader extends Downloader { await this.updateGameProgress(game.id, updatePayload, downloadStatus); }); + + this.download.on("end", async () => { + const updatePayload: QueryDeepPartialEntity = { + status: GameStatus.Finished, + progress: 1, + }; + + await this.updateGameProgress(game.id, updatePayload, { + timeRemaining: 0, + }); + }); } static destroy() {