Fix crashes related to cancel mirror
Signed-off-by: lzzy12 <jhashivam2020@gmail.com>
This commit is contained in:
parent
c1e4bf246c
commit
7b485d13b0
|
|
@ -30,8 +30,6 @@ def cancel_mirror(update: Update, context):
|
||||||
@run_async
|
@run_async
|
||||||
def cancel_all(update, context):
|
def cancel_all(update, context):
|
||||||
aria2.pause_all(True)
|
aria2.pause_all(True)
|
||||||
with download_dict_lock:
|
|
||||||
download_dict.clear()
|
|
||||||
sendMessage('Cancelled all downloads!', context, update)
|
sendMessage('Cancelled all downloads!', context, update)
|
||||||
|
|
||||||
clean_download(DOWNLOAD_DIR)
|
clean_download(DOWNLOAD_DIR)
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,11 @@ class MirrorListener(listeners.MirrorListeners):
|
||||||
if self.isTar:
|
if self.isTar:
|
||||||
with download_dict_lock:
|
with download_dict_lock:
|
||||||
download_dict[self.uid].is_archiving = True
|
download_dict[self.uid].is_archiving = True
|
||||||
path = fs_utils.tar(f'{DOWNLOAD_DIR}{self.uid}/{progress_status_list[index].name()}')
|
try:
|
||||||
|
path = fs_utils.tar(f'{DOWNLOAD_DIR}{self.uid}/{progress_status_list[index].name()}')
|
||||||
|
except FileNotFoundError:
|
||||||
|
self.onUploadError('Download cancelled!', progress_status_list, index)
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
path = f'{DOWNLOAD_DIR}{self.uid}/{progress_status_list[index].name()}'
|
path = f'{DOWNLOAD_DIR}{self.uid}/{progress_status_list[index].name()}'
|
||||||
name = pathlib.PurePath(path).name
|
name = pathlib.PurePath(path).name
|
||||||
|
|
@ -51,8 +55,15 @@ class MirrorListener(listeners.MirrorListeners):
|
||||||
LOGGER.error(error)
|
LOGGER.error(error)
|
||||||
with status_reply_dict_lock:
|
with status_reply_dict_lock:
|
||||||
if len(status_reply_dict) == 1:
|
if len(status_reply_dict) == 1:
|
||||||
deleteMessage(self.context, status_reply_dict[self.update.effective_chat.id])
|
try:
|
||||||
del status_reply_dict[self.update.effective_chat.id]
|
deleteMessage(self.context, status_reply_dict[self.update.effective_chat.id])
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
LOGGER.info(self.update.effective_chat.id)
|
||||||
|
try:
|
||||||
|
del status_reply_dict[self.update.effective_chat.id]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
with download_dict_lock:
|
with download_dict_lock:
|
||||||
del download_dict[self.uid]
|
del download_dict[self.uid]
|
||||||
fs_utils.clean_download(progress_status_list[index].path())
|
fs_utils.clean_download(progress_status_list[index].path())
|
||||||
|
|
@ -80,7 +91,7 @@ class MirrorListener(listeners.MirrorListeners):
|
||||||
|
|
||||||
def onUploadError(self, error: str, progress_status: list, index: int):
|
def onUploadError(self, error: str, progress_status: list, index: int):
|
||||||
LOGGER.error(error)
|
LOGGER.error(error)
|
||||||
editMessage(error, self.context, self.reply_message)
|
sendMessage(error, self.context, self.update)
|
||||||
with download_dict_lock:
|
with download_dict_lock:
|
||||||
del download_dict[self.message.message_id]
|
del download_dict[self.message.message_id]
|
||||||
fs_utils.clean_download(progress_status[index].path())
|
fs_utils.clean_download(progress_status[index].path())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue