diff --git a/bot/helper/mirror_utils/download_utils/mega_downloader.py b/bot/helper/mirror_utils/download_utils/mega_downloader.py index 27d1efd..a7a52e1 100644 --- a/bot/helper/mirror_utils/download_utils/mega_downloader.py +++ b/bot/helper/mirror_utils/download_utils/mega_downloader.py @@ -11,6 +11,8 @@ class MegaDownloaderException(Exception): class MegaAppListener(MegaListener): + _NO_EVENT_ON = (MegaRequest.TYPE_LOGIN, + MegaRequest.TYPE_FETCH_NODES) def __init__(self, continue_event: threading.Event, listener): self.continue_event = continue_event @@ -58,15 +60,14 @@ class MegaAppListener(MegaListener): .format(request, error)) request_type = request.getType() - if request_type == MegaRequest.TYPE_GET_PUBLIC_NODE: - self.node = request.getPublicMegaNode() if request_type == MegaRequest.TYPE_LOGIN: - LOGGER.info("Fetching Nodes.") api.fetchNodes() - if request_type == MegaRequest.TYPE_FETCH_NODES: + elif request_type == MegaRequest.TYPE_GET_PUBLIC_NODE: + self.node = request.getPublicMegaNode() + elif request_type == MegaRequest.TYPE_FETCH_NODES: LOGGER.info("Fetching Root Node.") self.node = api.getRootNode() - if request_type != MegaRequest.TYPE_LOGIN: + if request_type not in self._NO_EVENT_ON: self.continue_event.set() def onRequestTemporaryError(self, api, request, error: MegaError):