#1095 Fix crash for shares larger than 2GB. #1089 add ETA/bytes uploaded in progress bar of ReceiveMode items

This commit is contained in:
Miguel Jacq 2020-05-28 14:15:11 +10:00
parent 1c424500f0
commit cefa271d29
No known key found for this signature in database
GPG Key ID: EEA4341C6D97A0B6

View File

@ -119,7 +119,7 @@ class ShareHistoryItem(HistoryItem):
self.progress_bar.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.progress_bar.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.progress_bar.setAlignment(QtCore.Qt.AlignHCenter) self.progress_bar.setAlignment(QtCore.Qt.AlignHCenter)
self.progress_bar.setMinimum(0) self.progress_bar.setMinimum(0)
self.progress_bar.setMaximum(total_bytes) self.progress_bar.setMaximum(total_bytes / 1024)
self.progress_bar.setValue(0) self.progress_bar.setValue(0)
self.progress_bar.setStyleSheet( self.progress_bar.setStyleSheet(
self.common.gui.css["downloads_uploads_progress_bar"] self.common.gui.css["downloads_uploads_progress_bar"]
@ -138,8 +138,8 @@ class ShareHistoryItem(HistoryItem):
def update(self, downloaded_bytes): def update(self, downloaded_bytes):
self.downloaded_bytes = downloaded_bytes self.downloaded_bytes = downloaded_bytes
self.progress_bar.setValue(downloaded_bytes) self.progress_bar.setValue(downloaded_bytes / 1024)
if downloaded_bytes == self.progress_bar.total_bytes: if (downloaded_bytes / 1024) == (self.progress_bar.total_bytes / 1024):
pb_fmt = strings._("gui_all_modes_progress_complete").format( pb_fmt = strings._("gui_all_modes_progress_complete").format(
self.common.format_seconds(time.time() - self.started) self.common.format_seconds(time.time() - self.started)
) )
@ -322,8 +322,8 @@ class ReceiveHistoryItem(HistoryItem):
total_uploaded_bytes += data["progress"][filename]["uploaded_bytes"] total_uploaded_bytes += data["progress"][filename]["uploaded_bytes"]
# Update the progress bar # Update the progress bar
self.progress_bar.setMaximum(self.content_length) self.progress_bar.setMaximum(self.content_length / 1024)
self.progress_bar.setValue(total_uploaded_bytes) self.progress_bar.setValue(total_uploaded_bytes / 1024)
elapsed = datetime.now() - self.started elapsed = datetime.now() - self.started
if elapsed.seconds < 10: if elapsed.seconds < 10:
@ -339,6 +339,8 @@ class ReceiveHistoryItem(HistoryItem):
estimated_time_remaining, estimated_time_remaining,
) )
self.progress_bar.setFormat(pb_fmt)
# Using list(progress) to avoid "RuntimeError: dictionary changed size during iteration" # Using list(progress) to avoid "RuntimeError: dictionary changed size during iteration"
for filename in list(data["progress"]): for filename in list(data["progress"]):
# Add a new file if needed # Add a new file if needed
@ -461,7 +463,7 @@ class IndividualFileHistoryItem(HistoryItem):
self.downloaded_bytes = downloaded_bytes self.downloaded_bytes = downloaded_bytes
self.progress_bar.setValue(downloaded_bytes) self.progress_bar.setValue(downloaded_bytes)
if downloaded_bytes == self.progress_bar.total_bytes: if (downloaded_bytes / 1024 ) == (self.progress_bar.total_bytes / 1024):
self.status_code_label.setText("200") self.status_code_label.setText("200")
self.status_code_label.setStyleSheet( self.status_code_label.setStyleSheet(
self.common.gui.css["history_individual_file_status_code_label_2xx"] self.common.gui.css["history_individual_file_status_code_label_2xx"]