Fix downloads with unknown size with WebEngine

This commit is contained in:
Florian Bruhin 2016-11-08 09:05:46 +01:00
parent ed3347365f
commit 19c7d747dd
2 changed files with 9 additions and 1 deletions

View File

@ -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 = '?'

View File

@ -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