mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-09 03:37:45 +03:00
Merge branch 'feature/seed-completed-downloads' into feat/achievements-points
This commit is contained in:
commit
7b724d4185
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,5 @@
|
|||||||
.vscode/
|
.vscode/
|
||||||
node_modules/
|
node_modules/
|
||||||
fastlist.exe
|
|
||||||
__pycache__
|
__pycache__
|
||||||
dist
|
dist
|
||||||
out
|
out
|
||||||
|
@ -199,8 +199,8 @@
|
|||||||
"no_downloads_description": "Você ainda não baixou nada pelo Hydra, mas nunca é tarde para começar.",
|
"no_downloads_description": "Você ainda não baixou nada pelo Hydra, mas nunca é tarde para começar.",
|
||||||
"checking_files": "Verificando arquivos…",
|
"checking_files": "Verificando arquivos…",
|
||||||
"seeding": "Semeando",
|
"seeding": "Semeando",
|
||||||
"stop_seeding": "Parar semeio",
|
"stop_seeding": "Parar de semear",
|
||||||
"resume_seeding": "Retomar semeio",
|
"resume_seeding": "Semear",
|
||||||
"options": "Gerenciar"
|
"options": "Gerenciar"
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
|
@ -2,6 +2,7 @@ import { registerEvent } from "../register-event";
|
|||||||
import { DownloadManager, HydraApi, gamesPlaytime } from "@main/services";
|
import { DownloadManager, HydraApi, gamesPlaytime } from "@main/services";
|
||||||
import { dataSource } from "@main/data-source";
|
import { dataSource } from "@main/data-source";
|
||||||
import { DownloadQueue, Game, UserAuth, UserSubscription } from "@main/entity";
|
import { DownloadQueue, Game, UserAuth, UserSubscription } from "@main/entity";
|
||||||
|
import { PythonRPC } from "@main/services/python-rpc";
|
||||||
|
|
||||||
const signOut = async (_event: Electron.IpcMainInvokeEvent) => {
|
const signOut = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||||
const databaseOperations = dataSource
|
const databaseOperations = dataSource
|
||||||
@ -27,8 +28,7 @@ const signOut = async (_event: Electron.IpcMainInvokeEvent) => {
|
|||||||
DownloadManager.cancelDownload();
|
DownloadManager.cancelDownload();
|
||||||
|
|
||||||
/* Disconnects libtorrent */
|
/* Disconnects libtorrent */
|
||||||
// TODO
|
PythonRPC.kill();
|
||||||
// TorrentDownloader.killTorrent();
|
|
||||||
|
|
||||||
HydraApi.handleSignOut();
|
HydraApi.handleSignOut();
|
||||||
|
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
|
import { PythonRPC } from "@main/services/python-rpc";
|
||||||
|
|
||||||
const processProfileImage = async (
|
const processProfileImage = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
path: string
|
path: string
|
||||||
) => {
|
) => {
|
||||||
return path;
|
return PythonRPC.rpc.post<{ imagePath: string; mimeType: string }>(
|
||||||
// return PythonInstance.processProfileImage(path);
|
"/profile_image_processor/process_image",
|
||||||
|
{ path }
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
registerEvent("processProfileImage", processProfileImage);
|
registerEvent("processProfileImage", processProfileImage);
|
||||||
|
@ -8,11 +8,9 @@ const pauseGameSeed = async (
|
|||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
gameId: number
|
gameId: number
|
||||||
) => {
|
) => {
|
||||||
await dataSource.transaction(async (transactionalEntityManager) => {
|
await dataSource
|
||||||
await transactionalEntityManager
|
|
||||||
.getRepository(Game)
|
.getRepository(Game)
|
||||||
.update({ id: gameId }, { status: "complete", shouldSeed: false });
|
.update({ id: gameId }, { status: "complete", shouldSeed: false });
|
||||||
});
|
|
||||||
|
|
||||||
await DownloadManager.cancelDownload(gameId);
|
await DownloadManager.cancelDownload(gameId);
|
||||||
};
|
};
|
||||||
|
@ -20,11 +20,9 @@ const resumeGameSeed = async (
|
|||||||
|
|
||||||
if (!game) return;
|
if (!game) return;
|
||||||
|
|
||||||
await dataSource.transaction(async (transactionalEntityManager) => {
|
await dataSource
|
||||||
await transactionalEntityManager
|
|
||||||
.getRepository(Game)
|
.getRepository(Game)
|
||||||
.update({ id: gameId }, { status: "seeding", shouldSeed: true });
|
.update({ id: gameId }, { status: "seeding", shouldSeed: true });
|
||||||
});
|
|
||||||
|
|
||||||
await DownloadManager.startDownload(game);
|
await DownloadManager.startDownload(game);
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import { Ludusavi, startMainLoop } from "./services";
|
import { Ludusavi, startMainLoop } from "./services";
|
||||||
import {
|
import { userPreferencesRepository } from "./repository";
|
||||||
// downloadQueueRepository,
|
|
||||||
userPreferencesRepository,
|
|
||||||
} from "./repository";
|
|
||||||
import { UserPreferences } from "./entity";
|
import { UserPreferences } from "./entity";
|
||||||
import { RealDebridClient } from "./services/download/real-debrid";
|
import { RealDebridClient } from "./services/download/real-debrid";
|
||||||
import { HydraApi } from "./services/hydra-api";
|
import { HydraApi } from "./services/hydra-api";
|
||||||
@ -25,24 +22,7 @@ const loadState = async (userPreferences: UserPreferences | null) => {
|
|||||||
uploadGamesBatch();
|
uploadGamesBatch();
|
||||||
});
|
});
|
||||||
|
|
||||||
// const [nextQueueItem] = await downloadQueueRepository.find({
|
|
||||||
// order: {
|
|
||||||
// id: "DESC",
|
|
||||||
// },
|
|
||||||
// relations: {
|
|
||||||
// game: true,
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
PythonRPC.spawn();
|
PythonRPC.spawn();
|
||||||
// start download
|
|
||||||
|
|
||||||
// if (nextQueueItem?.game.status === "active") {
|
|
||||||
// DownloadManager.startDownload(nextQueueItem.game);
|
|
||||||
// } else {
|
|
||||||
// PythonInstance.spawn();
|
|
||||||
// }
|
|
||||||
|
|
||||||
startMainLoop();
|
startMainLoop();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ export class DownloadManager {
|
|||||||
public static async watchDownloads() {
|
public static async watchDownloads() {
|
||||||
const status = await this.getDownloadStatus();
|
const status = await this.getDownloadStatus();
|
||||||
|
|
||||||
// // status = await RealDebridDownloader.getStatus();
|
// status = await RealDebridDownloader.getStatus();
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
const { gameId, progress } = status;
|
const { gameId, progress } = status;
|
||||||
@ -180,61 +180,6 @@ export class DownloadManager {
|
|||||||
"on-seeding-status",
|
"on-seeding-status",
|
||||||
JSON.parse(JSON.stringify(seedStatus.data))
|
JSON.parse(JSON.stringify(seedStatus.data))
|
||||||
);
|
);
|
||||||
|
|
||||||
// const gamesToSeed = await gameRepository.find({
|
|
||||||
// where: { shouldSeed: true, isDeleted: false },
|
|
||||||
// });
|
|
||||||
// if (gamesToSeed.length === 0) return;
|
|
||||||
// const seedStatus = await PythonRPC.rpc
|
|
||||||
// .get<LibtorrentPayload[] | null>("/seed-status")
|
|
||||||
// .then((results) => {
|
|
||||||
// if (results === null) return [];
|
|
||||||
// return results.data;
|
|
||||||
// });
|
|
||||||
// if (!seedStatus.length === 0) {
|
|
||||||
// for (const game of gamesToSeed) {
|
|
||||||
// if (game.uri && game.downloadPath) {
|
|
||||||
// await this.resumeSeeding(game.id, game.uri, game.downloadPath);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// const gameIds = seedStatus.map((status) => status.gameId);
|
|
||||||
// for (const gameId of gameIds) {
|
|
||||||
// const game = await gameRepository.findOne({
|
|
||||||
// where: { id: gameId },
|
|
||||||
// });
|
|
||||||
// if (game) {
|
|
||||||
// const isNotDeleted = fs.existsSync(
|
|
||||||
// path.join(game.downloadPath!, game.folderName!)
|
|
||||||
// );
|
|
||||||
// if (!isNotDeleted) {
|
|
||||||
// await this.pauseSeeding(game.id);
|
|
||||||
// await gameRepository.update(game.id, {
|
|
||||||
// status: "complete",
|
|
||||||
// shouldSeed: false,
|
|
||||||
// });
|
|
||||||
// WindowManager.mainWindow?.webContents.send("on-hard-delete");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// const updateList = await gameRepository.find({
|
|
||||||
// where: {
|
|
||||||
// id: In(gameIds),
|
|
||||||
// status: Not(In(["complete", "seeding"])),
|
|
||||||
// shouldSeed: true,
|
|
||||||
// isDeleted: false,
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
// if (updateList.length > 0) {
|
|
||||||
// await gameRepository.update(
|
|
||||||
// { id: In(updateList.map((game) => game.id)) },
|
|
||||||
// { status: "seeding" }
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// WindowManager.mainWindow?.webContents.send(
|
|
||||||
// "on-seeding-status",
|
|
||||||
// JSON.parse(JSON.stringify(seedStatus))
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async pauseDownload() {
|
static async pauseDownload() {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
&__content {
|
&__content {
|
||||||
background-color: globals.$dark-background-color;
|
background-color: globals.$dark-background-color;
|
||||||
border: 1px solid globals.$border-color;
|
border: 1px solid globals.$border-color;
|
||||||
border-radius: 4px;
|
border-radius: 6px;
|
||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
@ -20,7 +20,16 @@ import {
|
|||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
} from "@renderer/components/dropdown-menu/dropdown-menu";
|
} from "@renderer/components/dropdown-menu/dropdown-menu";
|
||||||
import { ThreeBarsIcon } from "@primer/octicons-react";
|
import {
|
||||||
|
ColumnsIcon,
|
||||||
|
DownloadIcon,
|
||||||
|
LinkIcon,
|
||||||
|
PlayIcon,
|
||||||
|
ThreeBarsIcon,
|
||||||
|
TrashIcon,
|
||||||
|
UnlinkIcon,
|
||||||
|
XCircleIcon,
|
||||||
|
} from "@primer/octicons-react";
|
||||||
|
|
||||||
export interface DownloadGroupProps {
|
export interface DownloadGroupProps {
|
||||||
library: LibraryGame[];
|
library: LibraryGame[];
|
||||||
@ -168,10 +177,12 @@ export function DownloadGroup({
|
|||||||
label: t("install"),
|
label: t("install"),
|
||||||
disabled: deleting,
|
disabled: deleting,
|
||||||
onClick: () => openGameInstaller(game.id),
|
onClick: () => openGameInstaller(game.id),
|
||||||
|
icon: <DownloadIcon />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t("stop_seeding"),
|
label: t("stop_seeding"),
|
||||||
disabled: deleting,
|
disabled: deleting,
|
||||||
|
icon: <UnlinkIcon />,
|
||||||
show:
|
show:
|
||||||
game.status === "seeding" && game.downloader === Downloader.Torrent,
|
game.status === "seeding" && game.downloader === Downloader.Torrent,
|
||||||
onClick: () => pauseSeeding(game.id),
|
onClick: () => pauseSeeding(game.id),
|
||||||
@ -179,6 +190,7 @@ export function DownloadGroup({
|
|||||||
{
|
{
|
||||||
label: t("resume_seeding"),
|
label: t("resume_seeding"),
|
||||||
disabled: deleting,
|
disabled: deleting,
|
||||||
|
icon: <LinkIcon />,
|
||||||
show:
|
show:
|
||||||
game.status !== "seeding" && game.downloader === Downloader.Torrent,
|
game.status !== "seeding" && game.downloader === Downloader.Torrent,
|
||||||
onClick: () => resumeSeeding(game.id),
|
onClick: () => resumeSeeding(game.id),
|
||||||
@ -186,6 +198,7 @@ export function DownloadGroup({
|
|||||||
{
|
{
|
||||||
label: t("delete"),
|
label: t("delete"),
|
||||||
disabled: deleting,
|
disabled: deleting,
|
||||||
|
icon: <TrashIcon />,
|
||||||
onClick: () => openDeleteGameModal(game.id),
|
onClick: () => openDeleteGameModal(game.id),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -196,10 +209,12 @@ export function DownloadGroup({
|
|||||||
{
|
{
|
||||||
label: t("pause"),
|
label: t("pause"),
|
||||||
onClick: () => pauseDownload(game.id),
|
onClick: () => pauseDownload(game.id),
|
||||||
|
icon: <ColumnsIcon />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t("cancel"),
|
label: t("cancel"),
|
||||||
onClick: () => cancelDownload(game.id),
|
onClick: () => cancelDownload(game.id),
|
||||||
|
icon: <XCircleIcon />,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -211,10 +226,12 @@ export function DownloadGroup({
|
|||||||
game.downloader === Downloader.RealDebrid &&
|
game.downloader === Downloader.RealDebrid &&
|
||||||
!userPreferences?.realDebridApiToken,
|
!userPreferences?.realDebridApiToken,
|
||||||
onClick: () => resumeDownload(game.id),
|
onClick: () => resumeDownload(game.id),
|
||||||
|
icon: <PlayIcon />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t("cancel"),
|
label: t("cancel"),
|
||||||
onClick: () => cancelDownload(game.id),
|
onClick: () => cancelDownload(game.id),
|
||||||
|
icon: <XCircleIcon />,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
@ -290,7 +307,7 @@ export function DownloadGroup({
|
|||||||
<DropdownMenu
|
<DropdownMenu
|
||||||
align="end"
|
align="end"
|
||||||
items={getGameActions(game)}
|
items={getGameActions(game)}
|
||||||
sideOffset={-70}
|
sideOffset={-75}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
style={{
|
style={{
|
||||||
|
Loading…
Reference in New Issue
Block a user