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