mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 08:43:48 +03:00
feat: now the .rar file gets decompressed into the final directory of the game
This commit is contained in:
parent
0398164906
commit
a748135365
@ -3,6 +3,7 @@ import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import EasyDL from "easydl";
|
import EasyDL from "easydl";
|
||||||
import { GameStatus } from "@shared";
|
import { GameStatus } from "@shared";
|
||||||
|
import { fullArchive } from "node-7z-archive";
|
||||||
|
|
||||||
import { Downloader } from "./downloader";
|
import { Downloader } from "./downloader";
|
||||||
import { RealDebridClient } from "../real-debrid";
|
import { RealDebridClient } from "../real-debrid";
|
||||||
@ -62,13 +63,29 @@ export class RealDebridDownloader extends Downloader {
|
|||||||
|
|
||||||
this.download.on("end", async () => {
|
this.download.on("end", async () => {
|
||||||
const updatePayload: QueryDeepPartialEntity<Game> = {
|
const updatePayload: QueryDeepPartialEntity<Game> = {
|
||||||
status: GameStatus.Finished,
|
status: GameStatus.Decompressing,
|
||||||
progress: 1,
|
progress: 0.99,
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.updateGameProgress(game.id, updatePayload, {
|
await this.updateGameProgress(game.id, updatePayload, {
|
||||||
timeRemaining: 0,
|
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<Game> = {
|
||||||
|
status: GameStatus.Finished,
|
||||||
|
progress: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
await this.updateGameProgress(game.id, updatePayload, {
|
||||||
|
timeRemaining: 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ export enum GameStatus {
|
|||||||
CheckingFiles = "checking_files",
|
CheckingFiles = "checking_files",
|
||||||
DownloadingMetadata = "downloading_metadata",
|
DownloadingMetadata = "downloading_metadata",
|
||||||
Cancelled = "cancelled",
|
Cancelled = "cancelled",
|
||||||
|
Decompressing = "decompressing",
|
||||||
Finished = "finished",
|
Finished = "finished",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user