From eb518d40c55cd12bf404b03dd1ce07927118ae18 Mon Sep 17 00:00:00 2001 From: anas Date: Sat, 28 Aug 2021 08:08:27 +0300 Subject: [PATCH] minor fix Signed-off-by: anas --- .../download_utils/qbit_downloader.py | 15 ++++++++++----- .../status_utils/qbit_download_status.py | 3 ++- bot/modules/cancel_mirror.py | 2 +- qBittorrent.conf | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/bot/helper/mirror_utils/download_utils/qbit_downloader.py b/bot/helper/mirror_utils/download_utils/qbit_downloader.py index fd305cd2ebd..e75b41260b7 100644 --- a/bot/helper/mirror_utils/download_utils/qbit_downloader.py +++ b/bot/helper/mirror_utils/download_utils/qbit_downloader.py @@ -131,6 +131,7 @@ def add_torrent(self, link, dire, listener, qbitsel): def update(self): tor_info = self.client.torrents_info(torrent_hashes=self.ext_hash) if len(tor_info) == 0: + self.client.auth_log_out() self.updater.cancel() return try: @@ -138,8 +139,9 @@ def update(self): if tor_info.state == "metaDL": self.stalled_time = time.time() if time.time() - self.meta_time >= 999999999: # timeout while downloading metadata + self.client.torrents_pause(torrent_hashes=self.ext_hash) self.listener.onDownloadError("Dead Torrent!") - self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True) + self.client.torrents_delete(torrent_hashes=self.ext_hash) self.client.auth_log_out() self.updater.cancel() return @@ -156,21 +158,24 @@ def update(self): result = check_limit(size, TORRENT_DIRECT_LIMIT, TAR_UNZIP_LIMIT, is_tar_ext) self.checked = True if result: + self.client.torrents_pause(torrent_hashes=self.ext_hash) self.listener.onDownloadError(f"{mssg}.\nYour File/Folder size is {get_readable_file_size(size)}") - self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True) + self.client.torrents_delete(torrent_hashes=self.ext_hash) self.client.auth_log_out() self.updater.cancel() return elif tor_info.state == "stalledDL": if time.time() - self.stalled_time >= 999999999: # timeout after downloading metadata + self.client.torrents_pause(torrent_hashes=self.ext_hash) self.listener.onDownloadError("Dead Torrent!") - self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True) + self.client.torrents_delete(torrent_hashes=self.ext_hash) self.client.auth_log_out() self.updater.cancel() return elif tor_info.state == "error": + self.client.torrents_pause(torrent_hashes=self.ext_hash) self.listener.onDownloadError("Error. IDK why, report in @SlamBugReport") - self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True) + self.client.torrents_delete(torrent_hashes=self.ext_hash) self.client.auth_log_out() self.updater.cancel() return @@ -188,7 +193,7 @@ def update(self): if not os.listdir(dirpath): os.rmdir(dirpath) self.listener.onDownloadComplete() - self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True) + self.client.torrents_delete(torrent_hashes=self.ext_hash) self.client.auth_log_out() self.updater.cancel() except: diff --git a/bot/helper/mirror_utils/status_utils/qbit_download_status.py b/bot/helper/mirror_utils/status_utils/qbit_download_status.py index 458c6a760b3..fff0cfca972 100644 --- a/bot/helper/mirror_utils/status_utils/qbit_download_status.py +++ b/bot/helper/mirror_utils/status_utils/qbit_download_status.py @@ -77,5 +77,6 @@ def gid(self): def cancel_download(self): LOGGER.info(f"Cancelling Download: {self.name()}") + self.client.torrents_pause(torrent_hashes=self.__hash) self.listener.onDownloadError('Download stopped by user!') - self.client.torrents_delete(torrent_hashes=self.__hash, delete_files=True) + self.client.torrents_delete(torrent_hashes=self.__hash) diff --git a/bot/modules/cancel_mirror.py b/bot/modules/cancel_mirror.py index 369877f644a..dd484765cc7 100644 --- a/bot/modules/cancel_mirror.py +++ b/bot/modules/cancel_mirror.py @@ -49,7 +49,7 @@ def cancel_mirror(update, context): else: dl.download().cancel_download() sleep(3) # incase of any error with ondownloaderror listener - clean_download(f'{DOWNLOAD_DIR}{mirror_message.message_id}/') + clean_download(f'{DOWNLOAD_DIR}{mirror_message.message_id}') def cancel_all(update, context): diff --git a/qBittorrent.conf b/qBittorrent.conf index e15a01627f6..a4a07767e6d 100644 --- a/qBittorrent.conf +++ b/qBittorrent.conf @@ -9,7 +9,7 @@ Accepted=true Cookies=@Invalid() [BitTorrent] -Session\AsyncIOThreadsCount=8 +Session\AsyncIOThreadsCount=32 Session\BTProtocol=Both Session\MultiConnectionsPerIp=true Session\SlowTorrentsDownloadRate=100