From c92d95454d283c8675b0cbb79b7f7854afa75c09 Mon Sep 17 00:00:00 2001
From: Hafitz Setya <71178188+breakdowns@users.noreply.github.com>
Date: Fri, 11 Jun 2021 09:03:56 +0700
Subject: [PATCH] Fix cancel
---
.../download_utils/mega_downloader.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/bot/helper/mirror_utils/download_utils/mega_downloader.py b/bot/helper/mirror_utils/download_utils/mega_downloader.py
index 86399487abb..6e37d042047 100644
--- a/bot/helper/mirror_utils/download_utils/mega_downloader.py
+++ b/bot/helper/mirror_utils/download_utils/mega_downloader.py
@@ -65,8 +65,6 @@ def onRequestFinish(self, api, request, error):
.format(request, error))
if str(error).lower() != "no error":
self.error = error.copy()
- self.is_cancelled = True
- self.listener.onDownloadError("\nMEGA Link you are trying to download is no longer available.")
return
request_type = request.getType()
if request_type == MegaRequest.TYPE_LOGIN:
@@ -147,7 +145,7 @@ def __init__(self):
@new_thread
def add_download(mega_link: str, path: str, listener):
if MEGA_API_KEY is None:
- raise MegaDownloaderException('Mega API KEY not provided! Cannot mirror mega links')
+ raise MegaDownloaderException('Mega API KEY not provided! Cannot mirror Mega links')
executor = AsyncExecutor()
api = MegaApi(MEGA_API_KEY, None, None, 'telegram-mirror-bot')
global listeners
@@ -161,14 +159,16 @@ def add_download(mega_link: str, path: str, listener):
executor.do(api.getPublicNode, (mega_link,))
node = mega_listener.public_node
else:
- LOGGER.info("Logging into mega folder")
+ LOGGER.info("Logging into Mega folder")
folder_api = MegaApi(MEGA_API_KEY,None,None,'TgBot')
folder_api.addListener(mega_listener)
executor.do(folder_api.loginToFolder, (mega_link,))
node = folder_api.authorizeNode(mega_listener.node)
+ if mega_listener.error is not None:
+ return listener.onDownloadError(str(mega_listener.error))
if STOP_DUPLICATE_MEGA:
- msg = sendMessage('Check the File/Folder if already in drive...', listener.bot, listener.update)
- LOGGER.info(f'Check the File/Folder if already in drive')
+ msg = sendMessage('Check the File/Folder if already in Drive...', listener.bot, listener.update)
+ LOGGER.info(f'Check the File/Folder if already in Drive')
mname = node.getName()
if listener.isTar == True:
mname = mname + ".tar"
@@ -179,7 +179,7 @@ def add_download(mega_link: str, path: str, listener):
smsg, button = gd.drive_list(mname)
if smsg:
deleteMessage(listener.bot, msg)
- msg1 = "File/Folder is already available in Drive.\nHere are the search results:"
+ msg1 = "File/Folder is already available in Drive.\nHere are the search results:"
sendMarkup(msg1, listener.bot, listener.update, button)
return
else:
@@ -190,7 +190,7 @@ def add_download(mega_link: str, path: str, listener):
limit = MEGA_LIMIT
limit = limit.split(' ', maxsplit=1)
limitint = int(limit[0])
- msg3 = f'Failed, Mega limit is {MEGA_LIMIT}.\nYour File/Folder size is {get_readable_file_size(api.getSize(node))}.'
+ msg3 = f'Failed, Mega limit is {MEGA_LIMIT}.\nYour File/Folder size is {get_readable_file_size(api.getSize(node))}.'
if 'GB' in limit or 'gb' in limit:
if api.getSize(node) > limitint * 1024**3:
deleteMessage(listener.bot, msg2)