diff --git a/src/main/events/torrenting/pause-game-seed.ts b/src/main/events/torrenting/pause-game-seed.ts index d9a2a61a..5394ee20 100644 --- a/src/main/events/torrenting/pause-game-seed.ts +++ b/src/main/events/torrenting/pause-game-seed.ts @@ -3,11 +3,16 @@ 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) diff --git a/src/renderer/src/pages/downloads/downloads.tsx b/src/renderer/src/pages/downloads/downloads.tsx index 85a61b92..b0124a50 100644 --- a/src/renderer/src/pages/downloads/downloads.tsx +++ b/src/renderer/src/pages/downloads/downloads.tsx @@ -21,11 +21,13 @@ export default function Downloads() { const [showBinaryNotFoundModal, setShowBinaryNotFoundModal] = useState(false); const [showDeleteModal, setShowDeleteModal] = useState(false); - const { removeGameInstaller } = useDownload(); + const { removeGameInstaller, pauseSeeding } = useDownload(); const handleDeleteGame = async () => { - if (gameToBeDeleted.current) + if (gameToBeDeleted.current) { + await pauseSeeding(gameToBeDeleted.current); await removeGameInstaller(gameToBeDeleted.current); + } }; const { lastPacket } = useDownload(); diff --git a/torrent-client/torrent_downloader.py b/torrent-client/torrent_downloader.py index 41c45278..111eba62 100644 --- a/torrent-client/torrent_downloader.py +++ b/torrent-client/torrent_downloader.py @@ -195,6 +195,8 @@ class TorrentDownloader: if torrent_handle: torrent_handle.pause() 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): params = {'url': magnet, 'save_path': save_path, 'trackers': self.trackers}