Fix downloads with unknown size with WebEngine
This commit is contained in:
parent
ed3347365f
commit
19c7d747dd
@ -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 = '?'
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user