Changed sleep() call for Fixing Delay.
- Also Tweaked Torrent Metadata Status Logic a bit.
This commit is contained in:
parent
fa664e6663
commit
b7e65d9c9c
|
|
@ -12,3 +12,4 @@ data*
|
||||||
*.json
|
*.json
|
||||||
*.pickle
|
*.pickle
|
||||||
authorized_chats.txt
|
authorized_chats.txt
|
||||||
|
log.txt
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ class DownloadHelper:
|
||||||
should_update = True
|
should_update = True
|
||||||
if self.__is_torrent:
|
if self.__is_torrent:
|
||||||
# Waiting for the actual gid
|
# Waiting for the actual gid
|
||||||
new_gid = None
|
download = self.__get_download()
|
||||||
while new_gid is None:
|
while download.is_complete != True: # Check every few seconds
|
||||||
download = self.__get_download()
|
download = self.__get_download()
|
||||||
if download.has_failed:
|
if download.has_failed:
|
||||||
self.__listener.onDownloadError(download.error_message, status_list, index)
|
self.__listener.onDownloadError(download.error_message, status_list, index)
|
||||||
|
|
@ -50,13 +50,12 @@ class DownloadHelper:
|
||||||
if download.is_paused:
|
if download.is_paused:
|
||||||
self.__listener.onDownloadError("Download cancelled manually by user", status_list, index)
|
self.__listener.onDownloadError("Download cancelled manually by user", status_list, index)
|
||||||
return
|
return
|
||||||
sleep(DOWNLOAD_STATUS_UPDATE_INTERVAL)
|
|
||||||
if should_update:
|
if should_update:
|
||||||
try:
|
try:
|
||||||
self.__listener.onDownloadProgress(get_download_status_list(), index)
|
self.__listener.onDownloadProgress(get_download_status_list(), index)
|
||||||
except KillThreadException:
|
except KillThreadException:
|
||||||
should_update = False
|
should_update = False
|
||||||
# Check every few seconds
|
sleep(DOWNLOAD_STATUS_UPDATE_INTERVAL)
|
||||||
new_gid = self.__get_followed_download_gid()
|
new_gid = self.__get_followed_download_gid()
|
||||||
with download_dict_lock:
|
with download_dict_lock:
|
||||||
download_dict[self.__listener.message.message_id] = DownloadStatus(new_gid,
|
download_dict[self.__listener.message.message_id] = DownloadStatus(new_gid,
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ from bot import download_dict, aria2, dispatcher, download_dict_lock, DOWNLOAD_D
|
||||||
from bot.helper.telegram_helper.filters import CustomFilters
|
from bot.helper.telegram_helper.filters import CustomFilters
|
||||||
from bot.helper.ext_utils.fs_utils import clean_download
|
from bot.helper.ext_utils.fs_utils import clean_download
|
||||||
from bot.helper.telegram_helper.bot_commands import BotCommands
|
from bot.helper.telegram_helper.bot_commands import BotCommands
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
@run_async
|
@run_async
|
||||||
def cancel_mirror(update: Update, context):
|
def cancel_mirror(update: Update, context):
|
||||||
|
|
@ -28,6 +29,7 @@ def cancel_mirror(update: Update, context):
|
||||||
upload_helper = download_dict[mirror_message.message_id].upload_helper
|
upload_helper = download_dict[mirror_message.message_id].upload_helper
|
||||||
if upload_helper is not None:
|
if upload_helper is not None:
|
||||||
upload_helper.cancel()
|
upload_helper.cancel()
|
||||||
|
sleep(1) #Wait a Second For Aria2 To free Resources.
|
||||||
clean_download(f'{DOWNLOAD_DIR}{mirror_message.message_id}/')
|
clean_download(f'{DOWNLOAD_DIR}{mirror_message.message_id}/')
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -35,7 +37,7 @@ def cancel_mirror(update: Update, context):
|
||||||
def cancel_all(update, context):
|
def cancel_all(update, context):
|
||||||
aria2.pause_all(True)
|
aria2.pause_all(True)
|
||||||
sendMessage('Cancelled all downloads!', context, update)
|
sendMessage('Cancelled all downloads!', context, update)
|
||||||
|
sleep(1) #Wait a Second For Aria2 To free Resources.
|
||||||
clean_download(DOWNLOAD_DIR)
|
clean_download(DOWNLOAD_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue