mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
feat: pause seeding before deleting game
This commit is contained in:
parent
518d919da5
commit
f66bdd706b
@ -3,11 +3,16 @@ import { registerEvent } from "../register-event";
|
|||||||
import { DownloadManager } from "@main/services";
|
import { DownloadManager } from "@main/services";
|
||||||
import { dataSource } from "@main/data-source";
|
import { dataSource } from "@main/data-source";
|
||||||
import { Game } from "@main/entity";
|
import { Game } from "@main/entity";
|
||||||
|
import { gameRepository } from "@main/repository";
|
||||||
|
|
||||||
const pauseGameSeed = async (
|
const pauseGameSeed = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
gameId: number
|
gameId: number
|
||||||
) => {
|
) => {
|
||||||
|
const game = await gameRepository.findOneBy({ id: gameId });
|
||||||
|
|
||||||
|
if (game?.status !== "seeding") return;
|
||||||
|
|
||||||
await dataSource.transaction(async (transactionalEntityManager) => {
|
await dataSource.transaction(async (transactionalEntityManager) => {
|
||||||
await transactionalEntityManager
|
await transactionalEntityManager
|
||||||
.getRepository(Game)
|
.getRepository(Game)
|
||||||
|
@ -21,11 +21,13 @@ export default function Downloads() {
|
|||||||
const [showBinaryNotFoundModal, setShowBinaryNotFoundModal] = useState(false);
|
const [showBinaryNotFoundModal, setShowBinaryNotFoundModal] = useState(false);
|
||||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||||
|
|
||||||
const { removeGameInstaller } = useDownload();
|
const { removeGameInstaller, pauseSeeding } = useDownload();
|
||||||
|
|
||||||
const handleDeleteGame = async () => {
|
const handleDeleteGame = async () => {
|
||||||
if (gameToBeDeleted.current)
|
if (gameToBeDeleted.current) {
|
||||||
|
await pauseSeeding(gameToBeDeleted.current);
|
||||||
await removeGameInstaller(gameToBeDeleted.current);
|
await removeGameInstaller(gameToBeDeleted.current);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const { lastPacket } = useDownload();
|
const { lastPacket } = useDownload();
|
||||||
|
@ -195,6 +195,8 @@ class TorrentDownloader:
|
|||||||
if torrent_handle:
|
if torrent_handle:
|
||||||
torrent_handle.pause()
|
torrent_handle.pause()
|
||||||
torrent_handle.unset_flags(lt.torrent_flags.auto_managed)
|
torrent_handle.unset_flags(lt.torrent_flags.auto_managed)
|
||||||
|
self.session.remove_torrent(torrent_handle)
|
||||||
|
self.torrent_handles.pop(game_id, None)
|
||||||
|
|
||||||
def resume_seeding(self, game_id: int, magnet: str, save_path: str):
|
def resume_seeding(self, game_id: int, magnet: str, save_path: str):
|
||||||
params = {'url': magnet, 'save_path': save_path, 'trackers': self.trackers}
|
params = {'url': magnet, 'save_path': save_path, 'trackers': self.trackers}
|
||||||
|
Loading…
Reference in New Issue
Block a user