minor fix

Signed-off-by: anas <e.anastayyar@gmail.com>
This commit is contained in:
anas 2021-08-28 08:08:27 +03:00
parent 8341469643
commit eb518d40c5
4 changed files with 14 additions and 8 deletions

View File

@ -131,6 +131,7 @@ class qbittorrent:
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 @@ class qbittorrent:
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 @@ class qbittorrent:
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 @@ class qbittorrent:
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:

View File

@ -77,5 +77,6 @@ class QbDownloadStatus(Status):
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)

View File

@ -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):

View File

@ -9,7 +9,7 @@ Accepted=true
Cookies=@Invalid()
[BitTorrent]
Session\AsyncIOThreadsCount=8
Session\AsyncIOThreadsCount=32
Session\BTProtocol=Both
Session\MultiConnectionsPerIp=true
Session\SlowTorrentsDownloadRate=100