From 65303e3143cb3c0b7b04aa5954c746b57b2eae76 Mon Sep 17 00:00:00 2001 From: lzzy12 Date: Mon, 7 Oct 2019 23:05:05 +0530 Subject: [PATCH] Change status while archiving download Signed-off-by: lzzy12 --- bot/helper/ext_utils/bot_utils.py | 1 + bot/helper/mirror_utils/download_status.py | 3 +++ bot/modules/mirror.py | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bot/helper/ext_utils/bot_utils.py b/bot/helper/ext_utils/bot_utils.py index 454e178..db0c354 100644 --- a/bot/helper/ext_utils/bot_utils.py +++ b/bot/helper/ext_utils/bot_utils.py @@ -10,6 +10,7 @@ class MirrorStatus: STATUS_WAITING = "Queued" STATUS_FAILED = "Failed. Cleaning download" STATUS_CANCELLED = "Cancelled" + STATUS_ARCHIVING = "Archiving" PROGRESS_MAX_SIZE = 100 // 8 diff --git a/bot/helper/mirror_utils/download_status.py b/bot/helper/mirror_utils/download_status.py index 010a895..c036725 100644 --- a/bot/helper/mirror_utils/download_status.py +++ b/bot/helper/mirror_utils/download_status.py @@ -10,6 +10,7 @@ class DownloadStatus: def __init__(self, gid, message_id): self.upload_name = None + self.is_archiving = False self.__gid = gid self.__download = get_download(gid) self.__uid = message_id @@ -78,6 +79,8 @@ class DownloadStatus: def status(self): self.__update() status = None + if self.is_archiving: + status = MirrorStatus.STATUS_ARCHIVING if self.__download.is_waiting: status = MirrorStatus.STATUS_WAITING elif self.download().is_paused: diff --git a/bot/modules/mirror.py b/bot/modules/mirror.py index 1b03abf..dd9a2c3 100644 --- a/bot/modules/mirror.py +++ b/bot/modules/mirror.py @@ -31,11 +31,15 @@ class MirrorListener(listeners.MirrorListeners): def onDownloadComplete(self, progress_status_list, index: int): LOGGER.info(f"Download completed: {progress_status_list[index].name()}") if self.isTar: + with download_dict_lock: + download_dict[self.uid].is_archiving = True path = fs_utils.tar(f'{DOWNLOAD_DIR}{self.uid}/{progress_status_list[index].name()}') else: path = f'{DOWNLOAD_DIR}{self.uid}/{progress_status_list[index].name()}' name = pathlib.PurePath(path).name - download_dict[self.uid].upload_name = name + with download_dict_lock: + download_dict[self.uid].is_archiving = False + download_dict[self.uid].upload_name = name gdrive = gdriveTools.GoogleDriveHelper(self) gdrive.upload(name)