Skip to content

Commit b0f02dc

Browse files
committed
Use correct download size for progress bar
1 parent 0a2db78 commit b0f02dc

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/updater/download.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <https://www.gnu.org/licenses/>.
16-
16+
import logging
1717
from http.client import HTTPResponse
1818

1919
from PyQt5.QtCore import pyqtSignal
@@ -34,8 +34,19 @@ def chunked_download(
3434
:param size: the size of the download, in bytes; used for progress
3535
:param progress_signal: the PyQt signal with which to emit download progress
3636
"""
37+
if progress_signal is None:
38+
logging.warning(f"Progress signal is None.")
39+
3740
if not size:
38-
size = 10 ** 6 * 44
41+
length = response.headers.get("content-length")
42+
if length:
43+
length = int(length)
44+
logging.info(f"Download size is {length / 1024 ** 2:.1f}MB.")
45+
46+
size = length
47+
else:
48+
size = 10 ** 6 * 44
49+
logging.warning(f"Guessing download size.")
3950

4051
with open(filename, "wb") as f:
4152
bytes_downloaded = 0

0 commit comments

Comments
 (0)