Fix more crashes when mirror url is invalid
Signed-off-by: lzzy12 <jhashivam2020@gmail.com>
This commit is contained in:
parent
1fd10648ff
commit
6cc7f63410
|
|
@ -60,4 +60,7 @@ class DownloadStatus:
|
|||
|
||||
def download(self):
|
||||
self.__update()
|
||||
return self.__download
|
||||
return self.__download
|
||||
|
||||
def uid(self):
|
||||
return self.__uid
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ class DownloadHelper:
|
|||
|
||||
def add_download(self, link: str):
|
||||
download = None
|
||||
link = link.strip()
|
||||
if self.is_url(link):
|
||||
if link.endswith('.torrent'):
|
||||
self.__is_torrent = True
|
||||
|
|
@ -32,7 +33,8 @@ class DownloadHelper:
|
|||
download = aria2.add_magnet(link, {'dir': DOWNLOAD_DIR + str(self.__listener.message.message_id)})
|
||||
self.__is_torrent = True
|
||||
else:
|
||||
self.__listener.onDownloadError("No download URL or URL malformed", None, None)
|
||||
_list = get_download_status_list()
|
||||
self.__listener.onDownloadError("No download URL or URL malformed", get_download_status_list(), None)
|
||||
return
|
||||
download_dict[self.__listener.message.message_id] = DownloadStatus(download.gid,
|
||||
self.__listener.message.message_id)
|
||||
|
|
|
|||
|
|
@ -33,11 +33,12 @@ class MirrorListener(listeners.MirrorListeners):
|
|||
|
||||
def onDownloadError(self, error, progress_status_list: list, index: int):
|
||||
LOGGER.error(error)
|
||||
if progress_status_list is not None:
|
||||
deleteMessage(self.context, status_reply_dict[self.update.effective_chat.id])
|
||||
if index is not None:
|
||||
fs_utils.clean_download(progress_status_list[index].path())
|
||||
del download_dict[self.message.message_id]
|
||||
msg = f"@{self.message.from_user.username} your download has been cancelled due to: {error}"
|
||||
sendMessage(msg, self.context, self.update)
|
||||
del download_dict[self.message.message_id]
|
||||
|
||||
def onUploadStarted(self, progress_status_list: list, index: int):
|
||||
pass
|
||||
|
|
|
|||
Loading…
Reference in New Issue