Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
-fix stuck on uploading after selection from some torrents

Signed-off-by: anas <[email protected]>
  • Loading branch information
anasty17 authored and vincreator committed Aug 25, 2021
1 parent 2888ebb commit 741b788
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bot/helper/mirror_utils/download_utils/qbit_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def add_torrent(self, link, dire, listener, qbitsel):
tor_info = self.client.torrents_info(torrent_hashes=self.ext_hash)
if len(tor_info) > 0:
sendMessage("This torrent is already in list.", listener.bot, listener.update)
self.client.auth_log_out()
return
if is_file:
op = self.client.torrents_add(torrent_files=[link], save_path=dire)
Expand All @@ -64,6 +65,7 @@ def add_torrent(self, link, dire, listener, qbitsel):
while True:
if time.time() - self.meta_time >= 300:
sendMessage("The torrent was not added. report when u see this error", listener.bot, listener.update)
self.client.auth_log_out()
return False
tor_info = self.client.torrents_info(torrent_hashes=self.ext_hash)
if len(tor_info) > 0:
Expand Down Expand Up @@ -118,10 +120,12 @@ def add_torrent(self, link, dire, listener, qbitsel):
except qba.UnsupportedMediaType415Error as e:
LOGGER.error(str(e))
sendMessage("This is an unsupported/invalid link. {str(e)}", listener.bot, listener.update)
self.client.auth_log_out()
except Exception as e:
LOGGER.error(str(e))
sendMessage(str(e), listener.bot, listener.update)
self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True)
self.client.auth_log_out()


def update(self):
Expand All @@ -136,6 +140,7 @@ def update(self):
if time.time() - self.meta_time >= 600:
self.listener.onDownloadError("Dead Torrent!")
self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True)
self.client.auth_log_out()
self.updater.cancel()
return
elif tor_info.state == "downloading":
Expand All @@ -153,17 +158,20 @@ def update(self):
if result:
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.auth_log_out()
self.updater.cancel()
return
elif tor_info.state == "stalledDL":
if time.time() - self.stalled_time >= 900:
self.listener.onDownloadError("Dead Torrent!")
self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True)
self.client.auth_log_out()
self.updater.cancel()
return
elif tor_info.state == "error":
self.listener.onDownloadError("Error. IDK why, report in support group")
self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True)
self.client.auth_log_out()
self.updater.cancel()
return
elif tor_info.state == "uploading" or tor_info.state.lower().endswith("up"):
Expand All @@ -176,10 +184,12 @@ def update(self):
for folder in subdir:
if fnmatch(folder, ".unwanted"):
shutil.rmtree(os.path.join(dirpath, folder))
for dirpath, subdir, files in os.walk(f"{self.dire}", topdown=False):
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.auth_log_out()
self.updater.cancel()
except:
self.updater.cancel()
Expand Down
1 change: 1 addition & 0 deletions bot/modules/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def clean(self):
try:
aria2.purge()
get_client().torrents_delete(torrent_hashes="all", delete_files=True)
get_client().auth_log_out()
Interval[0].cancel()
del Interval[0]
delete_all_messages()
Expand Down

0 comments on commit 741b788

Please sign in to comment.