mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-31 14:51:02 +00:00
feat: added a Downloader helper to choose between real debrid and torrent when downloading
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { gameRepository } from "@main/repository";
|
||||
|
||||
import { registerEvent } from "../register-event";
|
||||
import { WindowManager, writePipe } from "@main/services";
|
||||
import { WindowManager } from "@main/services";
|
||||
|
||||
import { In } from "typeorm";
|
||||
import { Downloader } from "@main/services/donwloaders/downloader";
|
||||
import { GameStatus } from "@globals";
|
||||
|
||||
const cancelGameDownload = async (
|
||||
@@ -41,7 +42,7 @@ const cancelGameDownload = async (
|
||||
game.status !== GameStatus.Paused &&
|
||||
game.status !== GameStatus.Seeding
|
||||
) {
|
||||
writePipe.write({ action: "cancel" });
|
||||
Downloader.cancelDownload();
|
||||
if (result.affected) WindowManager.mainWindow.setProgressBar(-1);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { WindowManager, writePipe } from "@main/services";
|
||||
import { WindowManager } from "@main/services";
|
||||
|
||||
import { registerEvent } from "../register-event";
|
||||
import { gameRepository } from "../../repository";
|
||||
import { In } from "typeorm";
|
||||
import { Downloader } from "@main/services/donwloaders/downloader";
|
||||
import { GameStatus } from "@globals";
|
||||
|
||||
const pauseGameDownload = async (
|
||||
@@ -23,7 +24,7 @@ const pauseGameDownload = async (
|
||||
)
|
||||
.then((result) => {
|
||||
if (result.affected) {
|
||||
writePipe.write({ action: "pause" });
|
||||
Downloader.pauseDownload();
|
||||
WindowManager.mainWindow.setProgressBar(-1);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import { registerEvent } from "../register-event";
|
||||
import { gameRepository } from "../../repository";
|
||||
import { getDownloadsPath } from "../helpers/get-downloads-path";
|
||||
import { In } from "typeorm";
|
||||
import { writePipe } from "@main/services";
|
||||
import { Downloader } from "@main/services/donwloaders/downloader";
|
||||
import { GameStatus } from "@globals";
|
||||
|
||||
const resumeGameDownload = async (
|
||||
@@ -18,17 +18,12 @@ const resumeGameDownload = async (
|
||||
|
||||
if (!game) return;
|
||||
|
||||
writePipe.write({ action: "pause" });
|
||||
Downloader.resumeDownload();
|
||||
|
||||
if (game.status === GameStatus.Paused) {
|
||||
const downloadsPath = game.downloadPath ?? (await getDownloadsPath());
|
||||
|
||||
writePipe.write({
|
||||
action: "start",
|
||||
game_id: gameId,
|
||||
magnet: game.repack.magnet,
|
||||
save_path: downloadsPath,
|
||||
});
|
||||
Downloader.downloadGame(game, game.repack);
|
||||
|
||||
await gameRepository.update(
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ import { registerEvent } from "../register-event";
|
||||
import type { GameShop } from "@types";
|
||||
import { getImageBase64 } from "@main/helpers";
|
||||
import { In } from "typeorm";
|
||||
import { Downloader } from "@main/services/donwloaders/downloader";
|
||||
import { GameStatus } from "@globals";
|
||||
|
||||
const startGameDownload = async (
|
||||
@@ -35,7 +36,7 @@ const startGameDownload = async (
|
||||
return;
|
||||
}
|
||||
|
||||
writePipe.write({ action: "pause" });
|
||||
Downloader.pauseDownload();
|
||||
|
||||
await gameRepository.update(
|
||||
{
|
||||
@@ -61,12 +62,7 @@ const startGameDownload = async (
|
||||
}
|
||||
);
|
||||
|
||||
writePipe.write({
|
||||
action: "start",
|
||||
game_id: game.id,
|
||||
magnet: repack.magnet,
|
||||
save_path: downloadPath,
|
||||
});
|
||||
Downloader.downloadGame(game, repack);
|
||||
|
||||
game.status = GameStatus.DownloadingMetadata;
|
||||
|
||||
@@ -84,12 +80,7 @@ const startGameDownload = async (
|
||||
repack: { id: repackId },
|
||||
});
|
||||
|
||||
writePipe.write({
|
||||
action: "start",
|
||||
game_id: createdGame.id,
|
||||
magnet: repack.magnet,
|
||||
save_path: downloadPath,
|
||||
});
|
||||
Downloader.downloadGame(createdGame, repack);
|
||||
|
||||
const { repack: _, ...rest } = createdGame;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user