Fixed Cancelled Downloads stuck in Download Queue.
- Also some minor Modifications.
This commit is contained in:
parent
6ed78411fc
commit
fdb49ac62a
|
|
@ -43,6 +43,8 @@ class DownloadHelper:
|
|||
# Waiting for the actual gid
|
||||
download = self.__get_download()
|
||||
while download.is_complete != True: # Check every few seconds
|
||||
status_list = get_download_status_list()
|
||||
index = get_download_index(status_list, self.__get_download().gid)
|
||||
download = self.__get_download()
|
||||
if download.has_failed:
|
||||
self.__listener.onDownloadError(download.error_message, status_list, index)
|
||||
|
|
@ -55,7 +57,7 @@ class DownloadHelper:
|
|||
self.__listener.onDownloadProgress(get_download_status_list(), index)
|
||||
except KillThreadException:
|
||||
should_update = False
|
||||
sleep(DOWNLOAD_STATUS_UPDATE_INTERVAL)
|
||||
sleep(DOWNLOAD_STATUS_UPDATE_INTERVAL)
|
||||
new_gid = self.__get_followed_download_gid()
|
||||
with download_dict_lock:
|
||||
download_dict[self.__listener.message.message_id] = DownloadStatus(new_gid,
|
||||
|
|
@ -65,6 +67,8 @@ class DownloadHelper:
|
|||
previous = None
|
||||
download = self.__get_download()
|
||||
while not download.is_complete:
|
||||
status_list = get_download_status_list()
|
||||
index = get_download_index(status_list, self.__get_download().gid)
|
||||
if download.has_failed:
|
||||
self.__listener.onDownloadError(self.__get_download().error_message, status_list, index)
|
||||
return
|
||||
|
|
@ -72,8 +76,6 @@ class DownloadHelper:
|
|||
self.__listener.onDownloadError("Download has been canceled", status_list, index)
|
||||
return
|
||||
if should_update:
|
||||
status_list = get_download_status_list()
|
||||
index = get_download_index(status_list, self.__get_download().gid)
|
||||
# TODO: Find a better way to differentiate between 2 list of objects
|
||||
progress_str_list = get_download_str()
|
||||
if progress_str_list != previous:
|
||||
|
|
@ -82,7 +84,7 @@ class DownloadHelper:
|
|||
except KillThreadException:
|
||||
should_update = False
|
||||
previous = progress_str_list
|
||||
sleep(DOWNLOAD_STATUS_UPDATE_INTERVAL)
|
||||
download = self.__get_download()
|
||||
sleep(DOWNLOAD_STATUS_UPDATE_INTERVAL)
|
||||
|
||||
self.__listener.onDownloadComplete(status_list, index)
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class MirrorListener(listeners.MirrorListeners):
|
|||
name = pathlib.PurePath(path).name
|
||||
with download_dict_lock:
|
||||
download_dict[self.uid].is_archiving = False
|
||||
LOGGER.info(f"Upload Name : {name}")
|
||||
download_dict[self.uid].upload_name = name
|
||||
gdrive = gdriveTools.GoogleDriveHelper(self)
|
||||
with download_dict_lock:
|
||||
|
|
@ -67,7 +68,12 @@ class MirrorListener(listeners.MirrorListeners):
|
|||
except KeyError:
|
||||
pass
|
||||
with download_dict_lock:
|
||||
del download_dict[self.uid]
|
||||
LOGGER.info(f"Deleting {progress_status_list[index].name()} from download_dict.")
|
||||
try:
|
||||
del download_dict[self.uid]
|
||||
except KeyError as e:
|
||||
LOGGER.info(str(e))
|
||||
pass
|
||||
try:
|
||||
fs_utils.clean_download(progress_status_list[index].path())
|
||||
except FileNotFoundError:
|
||||
|
|
@ -79,7 +85,7 @@ class MirrorListener(listeners.MirrorListeners):
|
|||
pass
|
||||
|
||||
def onUploadComplete(self, link: str, progress_status_list: list, index: int):
|
||||
msg = f'<a href="{link}">{progress_status_list[index].name()}</a>'
|
||||
msg = f'<a href="{link}">{progress_status_list[index].name()}</a> ({progress_status_list[index].size()})'
|
||||
with download_dict_lock:
|
||||
del download_dict[self.message.message_id]
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in New Issue