diff --git a/bot/helper/mirror_utils/upload_utils/gdriveTools.py b/bot/helper/mirror_utils/upload_utils/gdriveTools.py index 61e611a73..e91850601 100644 --- a/bot/helper/mirror_utils/upload_utils/gdriveTools.py +++ b/bot/helper/mirror_utils/upload_utils/gdriveTools.py @@ -290,44 +290,31 @@ def clone(self, link): LOGGER.info(f"File ID: {file_id}") try: meta = self.getFileMetadata(file_id) - except Exception as e: - return f"{str(e).replace('>', '').replace('<', '')}" - if meta.get("mimeType") == self.__G_DRIVE_DIR_MIME_TYPE: - dir_id = self.create_directory(meta.get('name'), parent_id) - try: + if meta.get("mimeType") == self.__G_DRIVE_DIR_MIME_TYPE: + dir_id = self.create_directory(meta.get('name'), parent_id) result = self.cloneFolder(meta.get('name'), meta.get('name'), meta.get('id'), dir_id) - except Exception as e: - if isinstance(e, RetryError): - LOGGER.info(f"Total Attempts: {e.last_attempt.attempt_number}") - err = e.last_attempt.exception() - else: - err = str(e).replace('>', '').replace('<', '') - LOGGER.error(err) - return err - msg += f'{meta.get("name")}' \ - f' ({get_readable_file_size(self.transferred_size)})' - if INDEX_URL is not None: - url = requests.utils.requote_uri(f'{INDEX_URL}/{meta.get("name")}/') - msg += f' | Index URL' - else: - try: - file = self.copyFile(meta.get('id'), parent_id) - except Exception as e: - if isinstance(e, RetryError): - LOGGER.info(f"Total Attempts: {e.last_attempt.attempt_number}") - err = e.last_attempt.exception() - else: - err = str(e).replace('>', '').replace('<', '') - LOGGER.error(err) - return err - msg += f'{file.get("name")}' - try: - msg += f' ({get_readable_file_size(int(meta.get("size")))}) ' + msg += f'{meta.get("name")}' \ + f' ({get_readable_file_size(self.transferred_size)})' if INDEX_URL is not None: - url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}') + url = requests.utils.requote_uri(f'{INDEX_URL}/{meta.get("name")}/') msg += f' | Index URL' - except TypeError: - pass + else: + file = self.copyFile(meta.get('id'), parent_id) + msg += f'{file.get("name")}' + try: + msg += f' ({get_readable_file_size(int(meta.get("size")))}) ' + except TypeError: + pass + if INDEX_URL is not None: + url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}') + msg += f' | Index URL' + except Exception as err: + if isinstance(err, RetryError): + LOGGER.info(f"Total Attempts: {err.last_attempt.attempt_number}") + err = err.last_attempt.exception() + err = str(err).replace('>', '').replace('<', '') + LOGGER.error(err) + return err return msg def cloneFolder(self, name, local_path, folder_id, parent_id):