mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
fix: fixing errors with electron dl manager
This commit is contained in:
parent
11f1785432
commit
74a99f5bc8
51 changed files with 718 additions and 766 deletions
|
@ -6,9 +6,8 @@ import {
|
|||
getNewRepacksFromUser,
|
||||
getNewRepacksFromXatab,
|
||||
getNewRepacksFromOnlineFix,
|
||||
readPipe,
|
||||
startProcessWatcher,
|
||||
writePipe,
|
||||
DownloadManager,
|
||||
} from "./services";
|
||||
import {
|
||||
gameRepository,
|
||||
|
@ -17,39 +16,16 @@ import {
|
|||
steamGameRepository,
|
||||
userPreferencesRepository,
|
||||
} from "./repository";
|
||||
import { TorrentClient } from "./services/downloaders/torrent-client";
|
||||
import { Repack } from "./entity";
|
||||
import { TorrentDownloader } from "./services";
|
||||
import { Repack, UserPreferences } from "./entity";
|
||||
import { Notification } from "electron";
|
||||
import { t } from "i18next";
|
||||
import { GameStatus } from "@shared";
|
||||
import { In } from "typeorm";
|
||||
import { Downloader } from "./services/downloaders/downloader";
|
||||
import { GameStatus } from "@globals";
|
||||
import { RealDebridClient } from "./services/real-debrid";
|
||||
|
||||
startProcessWatcher();
|
||||
|
||||
TorrentClient.startTorrentClient(writePipe.socketPath, readPipe.socketPath);
|
||||
|
||||
Promise.all([writePipe.createPipe(), readPipe.createPipe()]).then(async () => {
|
||||
const game = await gameRepository.findOne({
|
||||
where: {
|
||||
status: In([
|
||||
GameStatus.Downloading,
|
||||
GameStatus.DownloadingMetadata,
|
||||
GameStatus.CheckingFiles,
|
||||
]),
|
||||
},
|
||||
relations: { repack: true },
|
||||
});
|
||||
|
||||
if (game) {
|
||||
Downloader.downloadGame(game, game.repack);
|
||||
}
|
||||
|
||||
readPipe.socket?.on("data", (data) => {
|
||||
TorrentClient.onSocketData(data);
|
||||
});
|
||||
});
|
||||
|
||||
const track1337xUsers = async (existingRepacks: Repack[]) => {
|
||||
for (const repacker of repackers) {
|
||||
await getNewRepacksFromUser(
|
||||
|
@ -59,11 +35,7 @@ const track1337xUsers = async (existingRepacks: Repack[]) => {
|
|||
}
|
||||
};
|
||||
|
||||
const checkForNewRepacks = async () => {
|
||||
const userPreferences = await userPreferencesRepository.findOne({
|
||||
where: { id: 1 },
|
||||
});
|
||||
|
||||
const checkForNewRepacks = async (userPreferences: UserPreferences | null) => {
|
||||
const existingRepacks = stateManager.getValue("repacks");
|
||||
|
||||
Promise.allSettled([
|
||||
|
@ -101,7 +73,7 @@ const checkForNewRepacks = async () => {
|
|||
});
|
||||
};
|
||||
|
||||
const loadState = async () => {
|
||||
const loadState = async (userPreferences: UserPreferences | null) => {
|
||||
const [friendlyNames, repacks, steamGames] = await Promise.all([
|
||||
repackerFriendlyNameRepository.find(),
|
||||
repackRepository.find({
|
||||
|
@ -121,6 +93,33 @@ const loadState = async () => {
|
|||
stateManager.setValue("steamGames", steamGames);
|
||||
|
||||
import("./events");
|
||||
|
||||
if (userPreferences?.realDebridApiToken)
|
||||
await RealDebridClient.authorize(userPreferences?.realDebridApiToken);
|
||||
|
||||
const game = await gameRepository.findOne({
|
||||
where: {
|
||||
status: In([
|
||||
GameStatus.Downloading,
|
||||
GameStatus.DownloadingMetadata,
|
||||
GameStatus.CheckingFiles,
|
||||
]),
|
||||
isDeleted: false,
|
||||
},
|
||||
relations: { repack: true },
|
||||
});
|
||||
|
||||
await TorrentDownloader.startClient();
|
||||
|
||||
if (game) {
|
||||
DownloadManager.resumeDownload(game.id);
|
||||
}
|
||||
};
|
||||
|
||||
loadState().then(() => checkForNewRepacks());
|
||||
userPreferencesRepository
|
||||
.findOne({
|
||||
where: { id: 1 },
|
||||
})
|
||||
.then((userPreferences) => {
|
||||
loadState(userPreferences).then(() => checkForNewRepacks(userPreferences));
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue