mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
fix: real debrid decompression happens in a folder that hydra recognises properly.
This commit is contained in:
parent
c5693e94af
commit
7ee5b73688
@ -10,6 +10,7 @@ import { TorrentUpdate } from "./torrent-client";
|
||||
import { HTTPDownloader } from "./http-downloader";
|
||||
import { Unrar } from "../unrar";
|
||||
import { GameStatus } from "@globals";
|
||||
import path from 'node:path';
|
||||
|
||||
interface DownloadStatus {
|
||||
numPeers: number;
|
||||
@ -23,7 +24,7 @@ export class Downloader {
|
||||
|
||||
static async usesRealDebrid() {
|
||||
const userPreferences = await userPreferencesRepository.findOne({ where: { id: 1 } });
|
||||
return userPreferences.realDebridApiToken !== null;
|
||||
return userPreferences!.realDebridApiToken !== null;
|
||||
}
|
||||
|
||||
static async cancelDownload() {
|
||||
@ -72,7 +73,7 @@ export class Downloader {
|
||||
const { links } = await RealDebridClient.getInfo(torrent.id);
|
||||
const { download } = await RealDebridClient.unrestrictLink(links[0]);
|
||||
this.lastHttpDownloader = new HTTPDownloader();
|
||||
this.lastHttpDownloader.download(download, game.downloadPath, game.id);
|
||||
this.lastHttpDownloader.download(download, game.downloadPath!, game.id);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@ -102,14 +103,14 @@ export class Downloader {
|
||||
body: t("game_ready_to_install", {
|
||||
ns: "notifications",
|
||||
lng: userPreferences.language,
|
||||
title: game.title,
|
||||
title: game?.title,
|
||||
}),
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
|
||||
if (gameUpdate.decompressionProgress === 0 && gameUpdate.status === GameStatus.Decompressing) {
|
||||
const unrar = await Unrar.fromFilePath(game.rarPath, game.downloadPath);
|
||||
if (game && gameUpdate.decompressionProgress === 0 && gameUpdate.status === GameStatus.Decompressing) {
|
||||
const unrar = await Unrar.fromFilePath(game.rarPath!, path.join(game.downloadPath!, game.folderName!));
|
||||
unrar.extract();
|
||||
this.updateGameProgress(gameId, {
|
||||
decompressionProgress: 1,
|
||||
@ -117,7 +118,7 @@ export class Downloader {
|
||||
}, downloadStatus);
|
||||
}
|
||||
|
||||
if (WindowManager.mainWindow) {
|
||||
if (WindowManager.mainWindow && game) {
|
||||
const progress = this.getGameProgress(game);
|
||||
WindowManager.mainWindow.setProgressBar(progress === 1 ? -1 : progress);
|
||||
|
||||
|
@ -5,6 +5,10 @@ import { WindowManager } from '../window-manager';
|
||||
import { Downloader } from './downloader';
|
||||
import { GameStatus } from '@globals';
|
||||
|
||||
function dropExtension(fileName: string) {
|
||||
return fileName.split('.').slice(0, -1).join('.');
|
||||
}
|
||||
|
||||
export class HTTPDownloader {
|
||||
private downloadManager: ElectronDownloadManager;
|
||||
private downloadId: string | null = null;
|
||||
@ -18,7 +22,7 @@ export class HTTPDownloader {
|
||||
|
||||
this.downloadId = await this.downloadManager.download({
|
||||
url,
|
||||
window: window,
|
||||
window: window!,
|
||||
callbacks: {
|
||||
onDownloadStarted: async (ev) => {
|
||||
const updatePayload: QueryDeepPartialEntity<Game> = {
|
||||
@ -27,6 +31,7 @@ export class HTTPDownloader {
|
||||
bytesDownloaded: 0,
|
||||
fileSize: ev.item.getTotalBytes(),
|
||||
rarPath: `${destination}/.rd/${ev.resolvedFilename}`,
|
||||
folderName: dropExtension(ev.resolvedFilename)
|
||||
};
|
||||
const downloadStatus = {
|
||||
numPeers: 0,
|
||||
|
Loading…
Reference in New Issue
Block a user