From 6fe360ebaa40eea8f68f57aa98ab7fa67fb510a6 Mon Sep 17 00:00:00 2001 From: lzzy12 Date: Fri, 11 Oct 2019 19:54:48 +0530 Subject: [PATCH] Delete the element from download_dict if the download failed Signed-off-by: lzzy12 --- bot/__init__.py | 4 ++++ bot/modules/mirror.py | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bot/__init__.py b/bot/__init__.py index eeddf25..6ce224c 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -38,7 +38,11 @@ BOT_TOKEN = None download_dict_lock = threading.Lock() status_reply_dict_lock = threading.Lock() +# Key: update.effective_chat.id +# Value: telegram.Message status_reply_dict = {} +# Key: update.message.message_id +# Value: An object of DownloadStatus download_dict = {} # Stores list of users and chats the bot is authorized to use in AUTHORIZED_CHATS = [] diff --git a/bot/modules/mirror.py b/bot/modules/mirror.py index 0d36e1b..505245d 100644 --- a/bot/modules/mirror.py +++ b/bot/modules/mirror.py @@ -52,9 +52,8 @@ class MirrorListener(listeners.MirrorListeners): if len(status_reply_dict) == 1: deleteMessage(self.context, status_reply_dict[self.update.effective_chat.id]) del status_reply_dict[self.update.effective_chat.id] - if index is not None: - with download_dict_lock: - del download_dict[self.message.message_id] + with download_dict_lock: + del download_dict[self.uid] fs_utils.clean_download(progress_status_list[index].path()) msg = f"@{self.message.from_user.username} your download has been stopped due to: {error}" sendMessage(msg, self.context, self.update)