mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-27 12:51:03 +00:00
feat: updated pauseGameSeed and resumeGameSeed events
This commit is contained in:
@@ -3,23 +3,22 @@ import { registerEvent } from "../register-event";
|
||||
import { DownloadManager } from "@main/services";
|
||||
import { dataSource } from "@main/data-source";
|
||||
import { Game } from "@main/entity";
|
||||
import { gameRepository } from "@main/repository";
|
||||
|
||||
|
||||
const pauseGameSeed = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number
|
||||
) => {
|
||||
const game = await gameRepository.findOneBy({ id: gameId });
|
||||
|
||||
if (game?.status !== "seeding") return;
|
||||
|
||||
await dataSource.transaction(async (transactionalEntityManager) => {
|
||||
await transactionalEntityManager
|
||||
.getRepository(Game)
|
||||
.update({ id: gameId }, { status: "complete", shouldSeed: false });
|
||||
.update(
|
||||
{ id: gameId },
|
||||
{ status: "complete", shouldSeed: false }
|
||||
);
|
||||
});
|
||||
|
||||
await DownloadManager.pauseSeeding(gameId);
|
||||
await DownloadManager.cancelDownload(gameId);
|
||||
};
|
||||
|
||||
registerEvent("pauseGameSeed", pauseGameSeed);
|
||||
|
||||
@@ -13,6 +13,8 @@ const resumeGameSeed = async (
|
||||
where: {
|
||||
id: gameId,
|
||||
isDeleted: false,
|
||||
downloader: 1,
|
||||
progress: 1,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -21,10 +23,13 @@ const resumeGameSeed = async (
|
||||
await dataSource.transaction(async (transactionalEntityManager) => {
|
||||
await transactionalEntityManager
|
||||
.getRepository(Game)
|
||||
.update({ id: gameId }, { status: "seeding", shouldSeed: true });
|
||||
.update(
|
||||
{ id: gameId },
|
||||
{ status: "seeding", shouldSeed: true }
|
||||
);
|
||||
});
|
||||
|
||||
await DownloadManager.resumeDownload(game);
|
||||
await DownloadManager.startDownload(game);
|
||||
};
|
||||
|
||||
registerEvent("resumeGameSeed", resumeGameSeed);
|
||||
|
||||
Reference in New Issue
Block a user