Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
Signed-off-by: anas <[email protected]>
  • Loading branch information
anasty17 committed Aug 28, 2021
1 parent 8341469 commit eb518d4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
15 changes: 10 additions & 5 deletions bot/helper/mirror_utils/download_utils/qbit_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,17 @@ 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:
tor_info = tor_info[0]
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
Expand All @@ -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
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion bot/helper/mirror_utils/status_utils/qbit_download_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion bot/modules/cancel_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion qBittorrent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Accepted=true
Cookies=@Invalid()

[BitTorrent]
Session\AsyncIOThreadsCount=8
Session\AsyncIOThreadsCount=32
Session\BTProtocol=Both
Session\MultiConnectionsPerIp=true
Session\SlowTorrentsDownloadRate=100
Expand Down

0 comments on commit eb518d4

Please sign in to comment.