From cefa271d29dbecb7d727c3ab509980de09db826f Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Thu, 28 May 2020 14:15:11 +1000 Subject: [PATCH 1/2] #1095 Fix crash for shares larger than 2GB. #1089 add ETA/bytes uploaded in progress bar of ReceiveMode items --- onionshare_gui/tab/mode/history.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/onionshare_gui/tab/mode/history.py b/onionshare_gui/tab/mode/history.py index 0797320e..1497813d 100644 --- a/onionshare_gui/tab/mode/history.py +++ b/onionshare_gui/tab/mode/history.py @@ -119,7 +119,7 @@ class ShareHistoryItem(HistoryItem): self.progress_bar.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.progress_bar.setAlignment(QtCore.Qt.AlignHCenter) 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.setStyleSheet( self.common.gui.css["downloads_uploads_progress_bar"] @@ -138,8 +138,8 @@ class ShareHistoryItem(HistoryItem): def update(self, downloaded_bytes): self.downloaded_bytes = downloaded_bytes - self.progress_bar.setValue(downloaded_bytes) - if downloaded_bytes == self.progress_bar.total_bytes: + self.progress_bar.setValue(downloaded_bytes / 1024) + if (downloaded_bytes / 1024) == (self.progress_bar.total_bytes / 1024): pb_fmt = strings._("gui_all_modes_progress_complete").format( self.common.format_seconds(time.time() - self.started) ) @@ -322,8 +322,8 @@ class ReceiveHistoryItem(HistoryItem): total_uploaded_bytes += data["progress"][filename]["uploaded_bytes"] # Update the progress bar - self.progress_bar.setMaximum(self.content_length) - self.progress_bar.setValue(total_uploaded_bytes) + self.progress_bar.setMaximum(self.content_length / 1024) + self.progress_bar.setValue(total_uploaded_bytes / 1024) elapsed = datetime.now() - self.started if elapsed.seconds < 10: @@ -339,6 +339,8 @@ class ReceiveHistoryItem(HistoryItem): estimated_time_remaining, ) + self.progress_bar.setFormat(pb_fmt) + # Using list(progress) to avoid "RuntimeError: dictionary changed size during iteration" for filename in list(data["progress"]): # Add a new file if needed @@ -461,7 +463,7 @@ class IndividualFileHistoryItem(HistoryItem): self.downloaded_bytes = 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.setStyleSheet( self.common.gui.css["history_individual_file_status_code_label_2xx"] From de81447b8f084037ba0dc2bff69982a9aef64000 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Tue, 30 Jun 2020 13:40:26 +1000 Subject: [PATCH 2/2] Set the maximum for the individual file history item to MB to avoid > 2GB crash --- onionshare_gui/tab/mode/history.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onionshare_gui/tab/mode/history.py b/onionshare_gui/tab/mode/history.py index 1497813d..f445efa6 100644 --- a/onionshare_gui/tab/mode/history.py +++ b/onionshare_gui/tab/mode/history.py @@ -453,7 +453,7 @@ class IndividualFileHistoryItem(HistoryItem): else: self.total_bytes = data["filesize"] self.progress_bar.setMinimum(0) - self.progress_bar.setMaximum(data["filesize"]) + self.progress_bar.setMaximum(data["filesize"] / 1024) self.progress_bar.total_bytes = data["filesize"] # Start at 0 @@ -462,7 +462,7 @@ class IndividualFileHistoryItem(HistoryItem): def update(self, downloaded_bytes): self.downloaded_bytes = downloaded_bytes - self.progress_bar.setValue(downloaded_bytes) + self.progress_bar.setValue(downloaded_bytes / 1024) if (downloaded_bytes / 1024 ) == (self.progress_bar.total_bytes / 1024): self.status_code_label.setText("200") self.status_code_label.setStyleSheet(