mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-24 03:11:03 +00:00
Merge branch 'feature/seed-completed-downloads' into feat/achievements-points
This commit is contained in:
@@ -2,6 +2,7 @@ import { registerEvent } from "../register-event";
|
||||
import { DownloadManager, HydraApi, gamesPlaytime } from "@main/services";
|
||||
import { dataSource } from "@main/data-source";
|
||||
import { DownloadQueue, Game, UserAuth, UserSubscription } from "@main/entity";
|
||||
import { PythonRPC } from "@main/services/python-rpc";
|
||||
|
||||
const signOut = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
const databaseOperations = dataSource
|
||||
@@ -27,8 +28,7 @@ const signOut = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
DownloadManager.cancelDownload();
|
||||
|
||||
/* Disconnects libtorrent */
|
||||
// TODO
|
||||
// TorrentDownloader.killTorrent();
|
||||
PythonRPC.kill();
|
||||
|
||||
HydraApi.handleSignOut();
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
import { PythonRPC } from "@main/services/python-rpc";
|
||||
|
||||
const processProfileImage = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
path: string
|
||||
) => {
|
||||
return path;
|
||||
// return PythonInstance.processProfileImage(path);
|
||||
return PythonRPC.rpc.post<{ imagePath: string; mimeType: string }>(
|
||||
"/profile_image_processor/process_image",
|
||||
{ path }
|
||||
);
|
||||
};
|
||||
|
||||
registerEvent("processProfileImage", processProfileImage);
|
||||
|
||||
@@ -8,11 +8,9 @@ const pauseGameSeed = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
) => {
|
||||
await dataSource.transaction(async (transactionalEntityManager) => {
|
||||
await transactionalEntityManager
|
||||
.getRepository(Game)
|
||||
.update({ id: gameId }, { status: "complete", shouldSeed: false });
|
||||
});
|
||||
await dataSource
|
||||
.getRepository(Game)
|
||||
.update({ id: gameId }, { status: "complete", shouldSeed: false });
|
||||
|
||||
await DownloadManager.cancelDownload(gameId);
|
||||
};
|
||||
|
||||
@@ -20,11 +20,9 @@ const resumeGameSeed = async (
|
||||
|
||||
if (!game) return;
|
||||
|
||||
await dataSource.transaction(async (transactionalEntityManager) => {
|
||||
await transactionalEntityManager
|
||||
.getRepository(Game)
|
||||
.update({ id: gameId }, { status: "seeding", shouldSeed: true });
|
||||
});
|
||||
await dataSource
|
||||
.getRepository(Game)
|
||||
.update({ id: gameId }, { status: "seeding", shouldSeed: true });
|
||||
|
||||
await DownloadManager.startDownload(game);
|
||||
};
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { Ludusavi, startMainLoop } from "./services";
|
||||
import {
|
||||
// downloadQueueRepository,
|
||||
userPreferencesRepository,
|
||||
} from "./repository";
|
||||
import { userPreferencesRepository } from "./repository";
|
||||
import { UserPreferences } from "./entity";
|
||||
import { RealDebridClient } from "./services/download/real-debrid";
|
||||
import { HydraApi } from "./services/hydra-api";
|
||||
@@ -25,24 +22,7 @@ const loadState = async (userPreferences: UserPreferences | null) => {
|
||||
uploadGamesBatch();
|
||||
});
|
||||
|
||||
// const [nextQueueItem] = await downloadQueueRepository.find({
|
||||
// order: {
|
||||
// id: "DESC",
|
||||
// },
|
||||
// relations: {
|
||||
// game: true,
|
||||
// },
|
||||
// });
|
||||
|
||||
PythonRPC.spawn();
|
||||
// start download
|
||||
|
||||
// if (nextQueueItem?.game.status === "active") {
|
||||
// DownloadManager.startDownload(nextQueueItem.game);
|
||||
// } else {
|
||||
// PythonInstance.spawn();
|
||||
// }
|
||||
|
||||
startMainLoop();
|
||||
};
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ export class DownloadManager {
|
||||
public static async watchDownloads() {
|
||||
const status = await this.getDownloadStatus();
|
||||
|
||||
// // status = await RealDebridDownloader.getStatus();
|
||||
// status = await RealDebridDownloader.getStatus();
|
||||
|
||||
if (status) {
|
||||
const { gameId, progress } = status;
|
||||
@@ -180,61 +180,6 @@ export class DownloadManager {
|
||||
"on-seeding-status",
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user