Skip to content

Commit

Permalink
fix file already in list after cancel upload
Browse files Browse the repository at this point in the history
Signed-off-by: anas <[email protected]>
  • Loading branch information
anasty17 committed Sep 24, 2021
1 parent d384ccb commit 794d6ba
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bot/helper/mirror_utils/download_utils/qbit_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ 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.updater.cancel()
self.client.torrents_pause(torrent_hashes=self.ext_hash)
time.sleep(0.3)
self.listener.onDownloadError("Dead Torrent!")
self.client.torrents_delete(torrent_hashes=self.ext_hash)
self.client.auth_log_out()
self.updater.cancel()
elif tor_info.state == "downloading":
self.stalled_time = time.time()
if (TORRENT_DIRECT_LIMIT is not None or TAR_UNZIP_LIMIT is not None) and not self.checked:
Expand All @@ -164,29 +164,28 @@ def update(self):
result = check_limit(size, TORRENT_DIRECT_LIMIT, TAR_UNZIP_LIMIT, is_tar_ext)
self.checked = True
if result:
self.updater.cancel()
self.client.torrents_pause(torrent_hashes=self.ext_hash)
time.sleep(0.3)
self.listener.onDownloadError(f"{mssg}.\nYour File/Folder size is {get_readable_file_size(size)}")
self.client.torrents_delete(torrent_hashes=self.ext_hash)
self.client.auth_log_out()
self.updater.cancel()
elif tor_info.state == "stalledDL":
if time.time() - self.stalled_time >= 999999999: # timeout after downloading metadata
self.updater.cancel()
self.client.torrents_pause(torrent_hashes=self.ext_hash)
time.sleep(0.3)
self.listener.onDownloadError("Dead Torrent!")
self.client.torrents_delete(torrent_hashes=self.ext_hash)
self.client.auth_log_out()
self.updater.cancel()
elif tor_info.state == "error":
self.updater.cancel()
self.client.torrents_pause(torrent_hashes=self.ext_hash)
time.sleep(0.3)
self.listener.onDownloadError("No enough space for this torrent on device")
self.client.torrents_delete(torrent_hashes=self.ext_hash)
self.client.auth_log_out()
elif tor_info.state == "uploading" or tor_info.state.lower().endswith("up"):
self.updater.cancel()
elif tor_info.state == "uploading" or tor_info.state.lower().endswith("up"):
self.client.torrents_pause(torrent_hashes=self.ext_hash)
if self.qbitsel:
for dirpath, subdir, files in os.walk(f"{self.dire}", topdown=False):
Expand All @@ -202,6 +201,7 @@ def update(self):
self.listener.onDownloadComplete()
self.client.torrents_delete(torrent_hashes=self.ext_hash)
self.client.auth_log_out()
self.updater.cancel()
except:
self.updater.cancel()

Expand Down

0 comments on commit 794d6ba

Please sign in to comment.