diff --git a/src/main/services/downloaders/real-debrid.downloader.ts b/src/main/services/downloaders/real-debrid.downloader.ts index 2b283e2f..f70120b3 100644 --- a/src/main/services/downloaders/real-debrid.downloader.ts +++ b/src/main/services/downloaders/real-debrid.downloader.ts @@ -3,6 +3,7 @@ import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity import path from "node:path"; import EasyDL from "easydl"; import { GameStatus } from "@shared"; +import { fullArchive } from "node-7z-archive"; import { Downloader } from "./downloader"; import { RealDebridClient } from "../real-debrid"; @@ -62,13 +63,29 @@ export class RealDebridDownloader extends Downloader { this.download.on("end", async () => { const updatePayload: QueryDeepPartialEntity = { - status: GameStatus.Finished, - progress: 1, + status: GameStatus.Decompressing, + progress: 0.99, }; await this.updateGameProgress(game.id, updatePayload, { timeRemaining: 0, }); + + this.startDecompression(this.download.savedFilePath!, game); + }); + } + + static async startDecompression(rarFile: string, game: Game) { + const directory = path.join(game.downloadPath!, game.repack.title); + + await fullArchive(rarFile, directory); + const updatePayload: QueryDeepPartialEntity = { + status: GameStatus.Finished, + progress: 1, + }; + + await this.updateGameProgress(game.id, updatePayload, { + timeRemaining: 0, }); } diff --git a/src/shared/index.ts b/src/shared/index.ts index 20425fd2..bedf98fb 100644 --- a/src/shared/index.ts +++ b/src/shared/index.ts @@ -5,6 +5,7 @@ export enum GameStatus { CheckingFiles = "checking_files", DownloadingMetadata = "downloading_metadata", Cancelled = "cancelled", + Decompressing = "decompressing", Finished = "finished", }