From c26315219e5803f4c015528ba84bddd5122b8b85 Mon Sep 17 00:00:00 2001 From: Chubby Granny Chaser Date: Thu, 27 Jun 2024 17:38:20 +0100 Subject: [PATCH] fix: keeping last status available on rpc --- src/main/services/download/download-manager.ts | 2 +- src/main/services/download/torrent-downloader.ts | 4 ---- torrent-client/main.py | 6 ++---- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/services/download/download-manager.ts b/src/main/services/download/download-manager.ts index 2230919b..72ce14d7 100644 --- a/src/main/services/download/download-manager.ts +++ b/src/main/services/download/download-manager.ts @@ -74,7 +74,7 @@ export class DownloadManager { if (game.downloader === Downloader.RealDebrid) { throw new Error(); } else { - TorrentDownloader.resumeDownload(game); + TorrentDownloader.startDownload(game); this.currentDownloader = Downloader.Torrent; } } diff --git a/src/main/services/download/torrent-downloader.ts b/src/main/services/download/torrent-downloader.ts index e9e9cff6..3e509bf5 100644 --- a/src/main/services/download/torrent-downloader.ts +++ b/src/main/services/download/torrent-downloader.ts @@ -123,10 +123,6 @@ export class TorrentDownloader { this.downloadingGameId = -1; } - static resumeDownload(game: Game) { - this.startDownload(game); - } - static async startDownload(game: Game) { if (!this.torrentClient) this.spawn(); diff --git a/torrent-client/main.py b/torrent-client/main.py index 37f646e7..96d0ce00 100644 --- a/torrent-client/main.py +++ b/torrent-client/main.py @@ -36,7 +36,6 @@ def pause_download(game_id: int): torrent_handle.pause() torrent_handle.unset_flags(lt.torrent_flags.auto_managed) downloading_game_id = -1 - Handler.current_status = None def cancel_download(game_id: int): global torrent_handles @@ -48,7 +47,6 @@ def cancel_download(game_id: int): session.remove_torrent(torrent_handle) torrent_handles[game_id] = None downloading_game_id =-1 - Handler.current_status = None def get_download_updates(): global torrent_handles @@ -78,8 +76,6 @@ def get_download_updates(): if status.progress == 1: cancel_download(downloading_game_id) - downloading_game_id = -1 - Handler.current_status = None time.sleep(0.5) @@ -105,8 +101,10 @@ class Handler(BaseHTTPRequestHandler): start_download(data['game_id'], data['magnet'], data['save_path']) elif data['action'] == 'pause': pause_download(data['game_id']) + self.current_status = None elif data['action'] == 'cancel': cancel_download(data['game_id']) + self.current_status = None self.send_response(200) self.end_headers()