From 19c7d747ddb0d01a34dac6a8d843a837353b216a Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 8 Nov 2016 09:05:46 +0100 Subject: [PATCH] Fix downloads with unknown size with WebEngine --- qutebrowser/browser/downloads.py | 4 +++- tests/end2end/features/downloads.feature | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index c83af523d..8684c6c13 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -240,7 +240,7 @@ class DownloadItemStats(QObject): bytes_done: How many bytes are downloaded. bytes_total: How many bytes there are to download in total. """ - if bytes_total == -1: + if bytes_total in [0, -1]: # QtWebEngine, QtWebKit bytes_total = None self.done = bytes_done self.total = bytes_total @@ -311,10 +311,12 @@ class AbstractDownloadItem(QObject): errmsg = "" else: errmsg = " - {}".format(self.error_msg) + if all(e is None for e in [perc, remaining, self.stats.total]): return ('{index}: {name} [{speed:>10}|{down}]{errmsg}'.format( index=self.index, name=self.basename, speed=speed, down=down, errmsg=errmsg)) + perc = round(perc) if remaining is None: remaining = '?' diff --git a/tests/end2end/features/downloads.feature b/tests/end2end/features/downloads.feature index 19a2081b3..aaf87dcf3 100644 --- a/tests/end2end/features/downloads.feature +++ b/tests/end2end/features/downloads.feature @@ -503,3 +503,9 @@ Feature: Downloading things from a website. And I wait until the download is finished Then the downloaded file download.bin should exist And the downloaded file download2.bin should not exist + + Scenario: Downloading a file with unknown size + When I set storage -> prompt-download-directory to false + And I open stream-bytes/1024 without waiting + And I wait until the download is finished + Then the downloaded file 1024 should exist