Use loop count instead of progress_bytes for upload progress
* We still have to find the best way to limit the update : Help needed Signed-off-by: lzzy12 <jhashivam2020@gmail.com>
This commit is contained in:
parent
3a8f284186
commit
e49445c603
|
|
@ -56,29 +56,27 @@ class GoogleDriveHelper:
|
|||
_list = get_download_status_list()
|
||||
index = get_download_index(_list, get_download(self.__listener.message.message_id).gid)
|
||||
uploaded_bytes = 0
|
||||
progress_change = 0
|
||||
chunk_size = 0
|
||||
loop_count = 0
|
||||
should_update = True
|
||||
while response is None:
|
||||
status, response = drive_file.next_chunk()
|
||||
time_lapsed = time.time() - self.start_time
|
||||
# Update the message only if status is not null and change in progress is more than 40 bytes
|
||||
if status:
|
||||
# Update the message only if status is not null and loop_count is multiple of 10
|
||||
if status and loop_count % 50 == 0:
|
||||
chunk_size = status.total_size * status.progress() - uploaded_bytes
|
||||
uploaded_bytes = status.total_size * status.progress()
|
||||
progress_change = uploaded_bytes - progress_change
|
||||
if progress_change >= 10*1024*1024:
|
||||
LOGGER.info(f'{file_name}: {status.progress() * 100}')
|
||||
|
||||
with download_dict_lock:
|
||||
download_dict[self.__listener.uid].uploaded_bytes += chunk_size
|
||||
download_dict[self.__listener.uid].upload_time = time_lapsed
|
||||
if should_update:
|
||||
try:
|
||||
self.__listener.onUploadProgress(_list, index)
|
||||
except KillThreadException:
|
||||
should_update = False
|
||||
progress_change = 0
|
||||
# LOGGER.info(f'{file_name}: {status.progress() * 100}')
|
||||
|
||||
with download_dict_lock:
|
||||
download_dict[self.__listener.uid].uploaded_bytes += chunk_size
|
||||
download_dict[self.__listener.uid].upload_time = time_lapsed
|
||||
if should_update:
|
||||
try:
|
||||
self.__listener.onUploadProgress(_list, index)
|
||||
except KillThreadException:
|
||||
should_update = False
|
||||
loop_count += 1
|
||||
|
||||
# Insert new permissions
|
||||
self.__service.permissions().create(fileId=response['id'], body=permissions).execute()
|
||||
|
|
|
|||
Loading…
Reference in New Issue